3 # call rsnapshot daily/weekly/monthly regularly
4 # this should be called from cron very often (several times a day) to not miss
5 # a cycle when the machine is powered down for extended times.
7 # Author: Martin Pitt <martin@piware.de>
8 # License: Public Domain
10 backupdir=`grep ^snapshot_root ~/.rsnapshotrc | awk '{print $2}'`
15 if [ -e $backupdir/$1 ]; then
16 age=$(($now - `stat -c %Y $backupdir/$1`))
22 # abort if last backup was less than a day ago
24 [ -n "$age" ] && [ $age -lt 86300 ] && exit 0
26 print '------------1---------------'
27 # monthly backup if last monthly is older than a month (if it doesn't exist,
28 # check oldest weekly)
30 [ -n "$age" ] || get_age weekly.3
31 [ -n "$age" ] && [ $age -ge 2591900 ] && mode=monthly
33 # weekly backup if last weekly is older than a week (if it doesn't exist,
36 [ -n "$age" ] || get_age daily.6
37 [ -n "$age" ] && [ $age -ge 604700 ] && mode=weekly
40 [ -n "$mode" ] || mode=daily
44 #notify-send "$mode backup started" || :
45 rsnapshot -c ~/.rsnapshotrc $mode
46 #notify-send "$mode backup finished" || :