summaryrefslogtreecommitdiff
path: root/bin/backup
blob: 2ee6b83344d9385e152e459599c12c9643d94b00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/sh

# incremental backup using rsync(1)

die() { echo "$0: fatal: $@" >&2; exit 1; }

[ "$(id -u)" = 0 ] || die must run as root

dest=${1:-bip:/home/backup}/$(hostname)
date=$(date +%Y%m%d_%H%M%S)
last=$(rsync --list-only $dest/ 2>/dev/null | cut -b 47- | tail -1)

case $last in
(2*) opt_link=--link-dest=../$last;;
(*) opt_link=;;
esac

rsync -DSHxav --exclude-from=/etc/backup/ignore $opt_link / /boot /home $dest/$date