-
Notifications
You must be signed in to change notification settings - Fork 0
/
rsync-backup
executable file
·47 lines (37 loc) · 1.12 KB
/
rsync-backup
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
#!/usr/bin/env bash
info() {
printf "\n%s %s\n\n" "$(date)" "$argv" >&2
}
trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM
info "Starting backup"
notify-send "rsync" "Starting daily backup..."
export BACKUP_LOCATION='/media/storage/backup/arch-backup/'
export BACKUP_LOCATION2='/media/storage/backup/arch-backup/home/rajeshkumar/'
sudo rsync -aAXHRv \
--delete \
--exclude caches/ \
--exclude-from "$HOME/data/rsync-backup-exclusions.txt" \
/etc \
/home \
/root \
/var \
/usr/local \
$BACKUP_LOCATION
sudo rsync -aAXHRv \
--delete \
--exclude caches/ \
--exclude-from "$HOME/data/rsync-backup-exclusions-2.txt" \
"$HOME" \
$BACKUP_LOCATION2
backup_exit=$?
if [ "$backup_exit" = "0" ]; then
info "Backup finished successfully"
notify-send "rsync" "Daily backup completed successfully."
elif [ "$backup_exit" = "1" ]; then
info "Backup finished with warnings"
notify-send "rsync" "Daily backup finished with warnings."
else
info "Backup and/or Prune finished with errors"
notify-send "rsync" "Daily backup was unsuccessful."
fi
exit $backup_exit