forked from laurent22/rsync-time-backup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
rsync-tmsched-conf-example.sh
116 lines (109 loc) · 3.21 KB
/
rsync-tmsched-conf-example.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
# shellcheck disable=SC2034
# Define your own schedule with sched_xxx and use it with [sched]=xxx
sched_daily() { true; }
sched_weekly() { [[ "$(date +%u)" == "1" ]]; }
sched_monthly() { [[ "$(date +%d)" == "01" ]]; }
# Coustom your notification command on backup finish
# $1: rsync-tmbackup return code
# $2: backup config name (the xxx part of conf_xxx)
notify() {
[[ "$1" -eq 0 ]] ||
: # Replace with a command to send email/push notification, etc.
}
# Note that this log dir is different from the rsync-tmbackup's --log-file
# option, which only saves the output of rsync. This log dir saves all output
# to rsync-tmsched.{log,err} files (in append mode).
#
# Logs won't automatically rotate. Remember to use logrotate or similar
# utilities to prevent disk fillup. Set to empty to diable logging.
RSCD_LOG_DIR="/var/log/rsync-backup"
# Custom variables
BR_DST1="/mnt/BACKUP1"
BR_DST2="/mnt/BACKUP2"
# Backup System1 root ---------------------------------------------------------
declare -A conf_System1_DST1=(
[src]="/"
[dst]="$BR_DST1/Sys1-root"
)
declare -a excl_System1_DST1=(
"- /swapfile"
"- /dev"
"- /proc"
"- /sys"
"- /tmp"
"- /run"
"- /mnt"
"- /media"
"- /lost+found"
"- /var/lib/dhcpcd/*"
"- /var/cache"
"- /home/*/.gvfs"
"- /home/*/.cache"
)
declare -A conf_System1_DST2=(
[src]="/"
[dst]="$BR_DST2/Sys1-root"
# Perform this backup weekly
[sched]='weekly'
)
declare -a excl_System1_DST2=(
"${excl_System1_DST1[@]}"
# Also exclude status files for archival backups
"- /var/log/"
"- /var/lib/"
"- /home/*/.local/share/fish/fish_history"
"- /home/*/.pyenv/shims/"
)
# Backup data directory -------------------------------------------------------
# Note that rsync-tmsched always append a slash '/' to source directory, so
# '/xxx' in the filter list matches '<source>/xxx'. There's no need to specify
# '/<source>/xxx' in the filter list.
declare -A conf_Data_DST1=(
[src]="/Data"
[dst]="$BR_DST1/Data"
)
declare -a excl_Data_DST1=(
# Backup only these directories under /Data
"+ /Documents/***"
"+ /Games/***"
"+ /Music/***"
"+ /Pictures/***"
"+ /Software/***"
"+ /Videos/***"
# Everything else is excluded
"- **"
)
# Backup remote server root ---------------------------------------------------
declare -A conf_Server_DST1=(
# Make sure proper ssh key is added and permissions configured
[src]="user@server:/"
[dst]="$BR_DST1/Server-root"
# Specify other options like this
['--id-rsa']="$HOME/.ssh/id_rsa"
# Dump database before backup. Use 'true' at the end to ignore dump errors
['--pre-sync-hook']='mysqldump -u root -pPASSWORD db_name > db.sql; true;'
)
declare -a excl_Server_DST1=(
# Home directories
"+ /home/*"
"- /home/*/.gvfs"
"- /home/*/.cache"
"+ /home/*/***"
# Nextcloud data
"+ /var/"
"+ /var/lib/"
"- /var/lib/nextcloud/sessions"
"+ /var/lib/nextcloud/***"
# Everything else is excluded
"- **"
)
declare -A conf_Server_DST2=(
[src]="user@server:/"
[dst]="$BR_DST2/Server-root"
# Perform this backup monthly
[sched]='monthly'
)
declare -a excl_Server_DST2=(
"${excl_Server_DST1[@]}"
)