#!/bin/tcsh
set mm=`date "+%m"`
set dy=`date "+%e"`
set ww=`date "+%u"`
setenv RSYNC_PASSWORD <put your rsync password here>
# you need to enable rsync on the server side also as a daemon
#also it is advisable to create a backup client
if (${dy} == 1) then
echo Monthly full Backup
rm /Volumes/Backup/$user/*_full_*
set date=`date "+%m%d%y"`
set fname="$user""_full_""$date"
set lname="$user""_full_""$date"".log"
cd ~
find . ! \( -iname "*cache*" -or -ipath "*Cache*" -or -ipath "*.Trash*" \) ! -type d -print >/tmp/backup.log
rsync -aogv --files-from=/tmp/backup.log . backup@bkupsrvcl1::Backup/${user}/full/${fname} --force --ignore-errors
#if you want to send a single compressed file you could use tar -cvzpf <with file as an input> then rsync the tar file
mkdir empty
rsync rsync -av --delete ./empty/ backup@bkupsrvcl1::Backup/${user}/incr/
rsync rsync -av --delete ./empty/ backup@bkupsrvcl1::Backup/${user}/diff/
rmdir empty
rm -f /tmp/backup.log
endif
if (${ww} == 5) then
echo Friday Diferential Backup
set date=`date "+%m%d%y"`
set fname="$user""_diff_""$date"
set lname="$user""_diff_""$date"".log"
cd ~
find . ! \( -iname "*cache*" -or -ipath "*Cache*" -or -ipath "*.Trash*" -or -type d \) -mtime "-"${dy} -print >/tmp/backup.log
rsync -aogv --files-from=/tmp/backup.log . backup@bkupsrvcl1::Backup/${user}/diff/${fname} --force --ignore-errors
mkdir empty
rsync rsync -av --delete ./empty/ backup@bkupsrvcl1::Backup/${user}/incr/
rmdir empty
rm -f /tmp/backup.log
endif
if (${ww}<5) then
echo Weekly incremental backup
set date=`date "+%m%d%y"`
set fname="$user""_incr_""$date"
set lname="$user""_incr_""$date"".log"
cd ~
find . ! \( -iname "*cache*" -or -ipath "*Cache*" -or -ipath "*.Trash*" \) ! -type d -mtime "-"1 -print >/tmp/backup.log
rsync -aogv --files-from=/tmp/backup.log . backup@bkupsrvcl1::Backup/${user}/incr/${fname} --force --ignore-errors
rm -f /tmp/backup.log
endif