-
Notifications
You must be signed in to change notification settings - Fork 0
/
,bkp_rsync.sh
executable file
·73 lines (65 loc) · 1.66 KB
/
,bkp_rsync.sh
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#!/bin/bash
MOUNT_LOCATION="/mnt/mydisk"
target_location="${MOUNT_LOCATION}/" #Intentional with /
EXCLUDE_PATTERNS=(
"--exclude=**/venv/**"
"--exclude=**/node_modules/**"
"--exclude=**/target/**" #maven
"--exclude=**/stratocyberlab/ollama/**"
)
dirs_to_bkp=(
"/home/adrian/adrian_knihy"
"/home/adrian/gits"
"/home/adrian/Applications"
"/home/adrian//Templates"
"/home/adrian/.vim"
"/opt/bin"
)
[[ "${EUID}" -eq 0 ]] || {
echo "This script must be run as root!" 1>&2
exit 1
}
{ mountpoint "${MOUNT_LOCATION}" -q; } || {
echo -e "Mount it in to:\n\t${MOUNT_LOCATION}" 1>&2
exit 1
}
for i in "${dirs_to_bkp[@]}"; do
[[ -d "${i}" ]] || {
echo "${i} does not exists!" 1>&2
exit 1
}
done
#-rauvlP
rsync_args=(
'--recursive'
# -a archive mode is -rlptgoD (no -A,-X,-U,-N,-H) https://www.baeldung.com/linux/rsync-archive-mode
'--archive'
# -u skip files that are newer on the receiver
'--update'
'--verbose'
# -l copy symlinks as symlinks
'--links'
'--progress'
# -L transform symlink into referent file/dir
#'--copy-links'
'--delete'
#"--exclude=${EXCLUDE_PATTERNS}"
"${EXCLUDE_PATTERNS[@]}"
)
: <<'END_TODO_REMOTE_TIME_MACHINE_LIKE'
#https://github.com/basnijholt/rsync-time-machine.py
'-D'
'--numeric-ids'
'--links'
'--hard-links'
'--one-file-system'
'--itemize-changes'
'--times'
'--recursive'
'--perms'
'--owner'
'--group'
'--stats'
'--human-readable'
END_TODO_REMOTE_TIME_MACHINE_LIKE
rsync "${rsync_args[@]}" "${dirs_to_bkp[@]}" "${target_location}"