-
Notifications
You must be signed in to change notification settings - Fork 1
/
rsync_backup.sh
executable file
·42 lines (37 loc) · 1005 Bytes
/
rsync_backup.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
#!/bin/bash
#rsync backup script
set -o errexit
set -o nounset
set -o pipefail
#Directories to exclude:
EXCLUDES=(
"--exclude=/dev/"
"--exclude=/var/tmp/"
"--exclude=/var/lock/"
"--exclude=/var/log/"
"--exclude=/var/run/"
"--exclude=/proc/"
"--exclude=/sys/"
"--exclude=/tmp/"
"--exclude=/run/"
"--exclude=/mnt/"
"--exclude=/media/"
"--exclude=/lost+found/"
"--exclude=/.snapshots/"
"--exclude=/home/steve/.local/share/steam"
"--exclude=/home/steve/Games"
"--exclude=/home/steve/SIOSTRA"
)
readonly SOURCE="/"
readonly DESTINATION="/mnt/SLON/pingwin_backup"
readonly DATETIME="$(date '+%Y-%m-%d_%H:%M')"
readonly BACKUP_PATH="${DESTINATION}/${DATETIME}"
readonly LATEST_LINK="${DESTINATION}/latest"
mkdir -p "${DESTINATION}"
sudo rsync -ahAX --info=progress2 --delete \
"${SOURCE}" \
--link-dest "${LATEST_LINK}" \
"${EXCLUDES[@]}" \
"${BACKUP_PATH}"
sudo rm -rf "${LATEST_LINK}"
ln -s "${BACKUP_PATH}" "${LATEST_LINK}"