-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackupfrom-remote
More file actions
executable file
·48 lines (40 loc) · 1.15 KB
/
Copy pathbackupfrom-remote
File metadata and controls
executable file
·48 lines (40 loc) · 1.15 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
#!/bin/bash
#
# backup selected directories/files,
# config file as argument
#
# the config file shall contain the variables:
#
# SRC_PATH_ABS absolute path to the files to backup, e.g. $HOME
# BACKUP_LIST list of files/directories to backup,
# the list may contain # comments and empty lines
# EXCLUDES_LIST list containing excludes, acc. to rsync --exclude-from
#
# DEST_PATH destination path, can be relative
#
# ADD_RSYNC_OPTS additional rsync options, e.g. used -R used for system backup
#
# includes
. common_f
check_config_arg "$1"
. "$1"
check_config_opts
create_dir "$DEST_PATH"
LOGFILE="$DEST_PATH"/daily.0.log
DATE=$(date "+%Y-%m-%d_%H:%M:%S")
echo "Backup start: $DATE" > "$LOGFILE"
# backup
rsync -av -i -r --numeric-ids \
-e "ssh -p $REMOTE_PORT" \
--files-from="$BACKUP_LIST" \
--exclude-from="$EXCLUDES_LIST" \
--delete \
$ADD_RSYNC_OPTS \
"$REMOTE_USER"@"$REMOTE_HOST":"$SRC_PATH_ABS" \
"$DEST_PATH"/daily.0 >> "$LOGFILE" 2>&1
# exit on failure
if [[ "$?" -ne 0 ]]; then
echo "A failure occured during rsync, exiting." >> "$LOGFILE"
exit 1
fi
echo "Backup end." >> "$LOGFILE"