#!/bin/bash src=$1 dst=$2 exclude="/Users/paul/bin/backup.exclude" if [ ! -d $src ] then echo "No source '$src'" exit -1 fi if [ ! -d $dst ] then echo "No destination '$dst'" exit -1 fi weekday=`date "+%w"` if [ $weekday -eq 0 -a -d "$dst/daily.6" ] then if [ -d "$dst/weekly.7" ] ; then rm -rf "$dst/weekly.7" ; fi if [ -d "$dst/weekly.6" ] ; then mv -f "$dst/weekly.6" "$dst/weekly.7" ; fi if [ -d "$dst/weekly.5" ] ; then mv -f "$dst/weekly.5" "$dst/weekly.6" ; fi if [ -d "$dst/weekly.4" ] ; then mv -f "$dst/weekly.4" "$dst/weekly.5" ; fi if [ -d "$dst/weekly.3" ] ; then mv -f "$dst/weekly.3" "$dst/weekly.4" ; fi if [ -d "$dst/weekly.2" ] ; then mv -f "$dst/weekly.2" "$dst/weekly.3" ; fi if [ -d "$dst/weekly.1" ] ; then mv -f "$dst/weekly.1" "$dst/weekly.2" ; fi if [ -d "$dst/weekly.0" ] ; then mv -f "$dst/weekly.0" "$dst/weekly.1" ; fi mv -f "$dst/daily.6" "$dst/weekly.0" fi if [ -d "$dst/daily.6" ] ; then rm -rf "$dst/daily.6" ; fi if [ -d "$dst/daily.5" ] ; then mv -f "$dst/daily.5" "$dst/daily.6" ; fi if [ -d "$dst/daily.4" ] ; then mv -f "$dst/daily.4" "$dst/daily.5" ; fi if [ -d "$dst/daily.3" ] ; then mv -f "$dst/daily.3" "$dst/daily.4" ; fi if [ -d "$dst/daily.2" ] ; then mv -f "$dst/daily.2" "$dst/daily.3" ; fi if [ -d "$dst/daily.1" ] ; then mv -f "$dst/daily.1" "$dst/daily.2" ; fi if [ -d "$dst/daily.0" ] ; then mv -f "$dst/daily.0" "$dst/daily.1" ; fi /usr/bin/rsync -a -E -S --exclude-from="$exclude" --link-dest="$dst/daily.1/" "$src/" "$dst/daily.0/"