aboutsummaryrefslogtreecommitdiffstats
path: root/bin/do-backup.sh
blob: 02350e555231a4ce6340f62a281dcf805f4074cc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash
#
# Dependencies: 'rsync'

backupdir=/mnt/storage/backups
logdir=$backupdir/logs
originserver="user@example.com"
tdate=$(date +%Y%m%d)

# Rsync options:
# a = archive mode (symbolic links, attributes, permissions,
#     ownerships, etc. are preserved in the transfer)
# z = compress file data during the transfer
# v = increase verbosity
# h = output numbers in a human-readable format
#
# A trailing *slash* on the _source_ changes this behavior to avoid
# creating an additional directory level at the _destination_.
mkdir -p $backupdir/$tdate && \
rsync -azvh --progress $originserver:/ \
	--exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} \
	"$backupdir/$tdate" \
	--log-file="$logdir/$tdate.log"