]> code.delx.au - monosys/blob - scripts/backup-generic
1ad6055c7e17907428b79b2e0c290a3a4208ac2f
[monosys] / scripts / backup-generic
1 #!/bin/bash -e
2
3 # Run this at a lower priority to avoid disrupting the rest of the system
4 ionice -c 3 -p $$
5 renice -n 19 -p $$ > /dev/null
6
7 (
8 # Only allow one backup to run at a time
9 if ! flock -n -x 200; then
10 echo "Failed to get a lock!"
11 exit 1
12 fi
13
14 # Exclude other filesystems from the backup. This leaves only the files we
15 # want, on the root file system, to back up.
16 # Also exclude other large collections of files which we don't care to save.
17 rdiff-backup \
18 --preserve-numerical-ids \
19 --exclude-sockets \
20 --exclude '/home/*/tmp' \
21 --include '/home' \
22 --exclude '/backup' \
23 --exclude '/tmp' \
24 --exclude '/var/cache' \
25 --exclude '/var/log' \
26 --include '/var' \
27 --exclude-other-filesystems \
28 / /backup/
29
30
31 # Remove old backups to free up some space
32 rdiff-backup -v1 --force --remove-older-than 365D /backup/
33
34 ) 200>/var/run/backup
35
36 exit 0
37