#!/bin/bash -e # Run this at a lower priority to avoid disrupting the rest of the system ionice -c 3 -p $$ renice -n 19 -p $$ > /dev/null ( # Only allow one backup to run at a time if ! flock -n -x 200; then echo "Failed to get a lock!" exit 1 fi # Exclude other filesystems from the backup. This leaves only the files we # want, on the root file system, to back up. # Also exclude other large collections of files which we don't care to save. rdiff-backup \ --preserve-numerical-ids \ --exclude-sockets \ --exclude '/home/*/tmp' \ --include '/home' \ --exclude '/backup' \ --exclude '/tmp' \ --exclude '/var/cache/apt/archives' \ --exclude '/var/log' \ --include '/var' \ --exclude-other-filesystems \ / /backup/ # Remove old backups to free up some space rdiff-backup -v1 --force --remove-older-than 365D /backup/ ) 200>/var/run/backup exit 0