-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhomesync.sh
More file actions
executable file
·52 lines (43 loc) · 1.09 KB
/
homesync.sh
File metadata and controls
executable file
·52 lines (43 loc) · 1.09 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
44
45
46
47
48
49
50
51
52
#!/bin/bash
### Home directory backup utility
### Modify to suit you needs
part_uuid="slsqdsd-515313-1151-aaaaa-aaaaaaaaaaaa"
dir_to_sync="/home/USER/"
local_dest="/media/.../Backups/USER_backup"
remote_dest="42.42.42.42:USER_backup"
function mount_filesystem () {
mount PARTUUID="$part_uuid"
}
function umount_filesystem () {
umount PARTUUID="$part_uuid"
}
function remotesync () {
DIR_TO_SYNC="$1"
REMOTE_DEST="$2"
rsync -auzvh --delete --exclude={'Videos/*','Downloads/*','Music/*','Pictures/*','Downloads/*','.cache/*','.mozilla/*',}\
"$DIR_TO_SYNC" "$REMOTE_DEST"
}
function localsync () {
DIR_TO_SYNC="$1"
LOCAL_DEST="$2"
rsync -auzvh --delete --exclude={'Videos/*','Downloads/*','Music/*','Downloads/*','.cache/*','.mozilla/*'}\
"$DIR_TO_SYNC" "$LOCAL_DEST"
}
echo "Automatic sync of home directory"
echo "1) local"
echo "2) remote"
echo "3) both"
read -r answer
case $answer in
1 )
localsync "$dir_to_sync" "$local_dest"
;;
2 )
remotesync "$dir_to_sync" "$remote_dest"
;;
3 )
remotesync "$dir_to_sync" "$remote_dest"
localsync "$dir_to_sync" "$local_dest"
;;
esac
exit 0