#!/bin/csh @ MAX_DAYS = 6 set DRYRUN = "" #set DRYRUN = "-nv" set ARCHIVE = "/archive/grotbags" echo "Grotbags: Daily Disk Snapshot [Start `date`]" cd / mount -oremount,rw /archive cd $ARCHIVE # First-off, rotate the backup directories echo "[Grotbags] `date` Rotating directories" if ( -d $MAX_DAYS ) then echo "[Grotbags] `date` Removing oldest" rm -rf $MAX_DAYS echo "[Grotbags] `date` Removing oldest -- DONE" endif @ target = $MAX_DAYS while ( $target > 0 ) @ source = $target - 1 set sf = "$source" set tf="$target" if ( -d $sf ) then mv $sf $tf endif @ target = $target - 1 end echo "[Grotbags] `date` Rotating directories -- DONE" echo "[Grotbags] `date` Taking copy" cp -al 1 0 echo "[Grotbags] `date` Taking copy -- DONE" rsync $DRYRUN --stats -aHx --delete / /archive/grotbags/0/root rsync $DRYRUN --stats -aHx --delete /usr /archive/grotbags/0 rsync $DRYRUN --stats -aHx --delete /var /archive/grotbags/0 cd / mount -oremount,ro /archive echo "Grotbags: Daily Disk Snapshot [End `date`]"