-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebsitesync.sh
More file actions
executable file
·45 lines (34 loc) · 1.16 KB
/
Copy pathwebsitesync.sh
File metadata and controls
executable file
·45 lines (34 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/bin/bash
### Uses rsync over ssh to upload your website from local to server
### or the other way around.
delete=0
direction="$1"
### Modify to suit your need :
website_local_path="/home/USER/www/mysuperwebsite/" # Don't forget the last `/` !
website_remote_path="/var/www/html/" # Don't forget the last `/` !
server="user@42.42.42.42"
if [[ "$2" == "delete" ]]; then
delete=1
fi
function syncto () {
if [[ $delete == 1 ]]; then
rsync -e ssh -azvuh --progress --delete "$website_local_path" "$server":"$website_remote_path"
else
rsync -e ssh -azvuh --progress "$website_local_path" "$server":"$website_remote_path"
fi
}
function syncfrom () {
if [[ $delete == 1 ]]; then
rsync -e ssh -azvuh --progress --delete "$server":"$website_remote_path" "$website_local_path"
else
rsync -e ssh -azvuh --progress "$server":"$website_remote_path" "$website_local_path"
fi
}
if [[ $direction == "to" ]]; then
syncto
elif [[ $direction == "from" ]]; then
syncfrom
else
echo -e "websitesync to : sync local dir to remote vps\nwebsitesync from : sync local dir from remote vps"
echo "You can add \"delete\" as a second argument (see rsync documentation)"
fi