Newbie Backup Script

Hello All,

I have attempted to write my first complex (to me) backup script. I am offering it to any and all who may find it useful but would like to refine it as well. I'm using it to backup a Mac OSX Lion Server to a USB Raid5. The script is actually comprised of a daily and a weekly script called by a plist file. Please provide any and all comments, corrections etc. Thanks in advance

#!/bin/sh
## DAILY BACKUP
##
Source1=/Volumes/Data/Aperture_Share
Source2=/Volumes/Data/iTunes_Share
Source3=/Volumes/Data/Public
Source4=/Users/admin
Destination=/Volumes/Backup/MediaServer/
Excludes=/Volumes/Backup/MediaServer/excludes.txt
Logfile=/Volumes/Backup/MediaServer/daily_logs/dailylog.txt
Logfilegzip=/Volumes/Backup/MediaServer/daily_logs/dailylog.txt.gz
##
diskutil mount /dev/disk3s2
echo "#######################################" >>$Logfile 
echo "***************************************" >>$Logfile
echo "~~~~~~~~Starting Daily Backup~~~~~~~~~~" >>$Logfile
date >>$Logfile
/usr/local/bin/rsync -avzxpP --stats --exclude-from=$Excludes $Source1 $Source2 $Source3 $Source4 $Destination/current/ >>$Logfile
date >>$Logfile
echo "~~~~~~~~Finished Daily Backup~~~~~~~~~~" >>$Logfile
echo "***************************************" >>$Logfile
echo "#######################################" >>$Logfile
##
gzip $Logfile
cp $Logfilegzip /Volumes/Backup/MediaServer/daily_logs/"`date +%m%d%y`_dailylog.txt.gz"
uuencode $Logfilegzip $Logfilegzip | mailx -s "Daily MediaServer Backup" user@gmail.com
rm $Logfilegzip
sleep 20
diskutil umount /dev/disk3s2
##
#!/bin/sh
## WEEKLY BACKUP
##
Source1=/Volumes/Data/Aperture_Share
Source2=/Volumes/Data/iTunes_Share
Source3=/Volumes/Data/Public
Source4=/Users/admin
Destination=/Volumes/Backup/MediaServer/
Excludes=/Volumes/Backup/MediaServer/excludes.txt
Logfile=/Volumes/Backup/MediaServer/weekly_logs/weeklylog.txt
Logfilegzip=/Volumes/Backup/MediaServer/weekly_logs/weeklylog.txt.gz
##
diskutil mount /dev/disk3s2
echo "#######################################" >>$Logfile
echo "***************************************" >>$Logfile
echo "~~~~~~~Starting Weekly Backup~~~~~~~~~~" >>$Logfile
date >>$Logfile
/usr/local/bin/rsync -avzxpP --stats --exclude-from=$Excludes $Source1 $Source2 $Source3 $Source4 $Destination/current/ >>$Logfile  
rm -rf $Destination/snapshot.3   
mv $Destination/snapshot.2 $Destination/snapshot.3  
mv $Destination/snapshot.1 $Destination/snapshot.2 
mv $Destination/snapshot.0 $Destination/snapshot.1 
cd $Destination/current
find . -print | cpio -dumpvl $Destination/snapshot.0
/usr/local/bin/rsync -avzxpP --stats --delete --exclude-from=$Excludes $Source1 $Source2 $Source3 $Source4 $Destination/current/ >>$Logfile  
date >>$Logfile
echo "~~~~~~~~Finished Weekly Backup~~~~~~~~~" >>$Logfile
echo "***************************************" >>$Logfile
echo "#######################################" >>$Logfile
##
gzip $Logfile
cp $Logfilegzip /Volumes/Backup/MediaServer/weekly_logs/"`date +%m%d%y`_weeklylog.txt.gz"
uuencode $Logfilegzip $Logfilegzip | mailx -s "Weekly MediaServer Backup" user@gmail.com
rm $Logfilegzip
sleep 20
diskutil umount /dev/disk3s2
##

I see posibly two issues; the device disk number could change and the uncanny ability of OS X to write directorties that aren't mount point to the /Volumes directory. So first I would query diskutil and mount for the proper device then run something like ->

for MNT in /Volumes/*
do
if [[ $(/usr/bin/stat -f "%d" "$MNT") = $(/usr/bin/stat -f "%d" "$MNT/..") ]]; then
 echo $MNT is NOT a file system mount point
fi
done

add this line to the top somewhere.

# The script must be run as root
#
if [ "$USER" != "root" ]; then
echo "Must be run as root"
exit 1
fi