Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the '10.4: Use rysnc to perform automatic backups' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: Use rysnc to perform automatic backups
Authored by: grasshoppermouse on May 17, '05 05:42:22AM
I was bitten by the following: if /Volumes/Backup is a removable drive, like a firewire drive, and it gets unplugged, rsyncx will create a folder in /Volumes named 'Backup', and write the files there. If you are mirroring the drive, as I was, this will completely fill the source hard drive, causing all kinds of problems. To help prevent this, I bracketed the script with an if-then statement checking that the backup drive exists before writing to it, as follows:

if [ -d "/Volumes/Backup/" ]; then

rsync code here

fi
Although I am no Unix expert, the following code seems to work well:

# Begin Backup Script
if [ -d "/Volumes/Backup/" ]; then
PATH=/bin:/sbin:/usr/sbin:/usr/bin:/usr/libexec:/usr/local/bin
export PATH
host=`hostname -s`
echo "Rsync to Backup"
sudo /usr/local/bin/rsync -a --delete --eahfs \
--exclude="/dev*" --exclude="/private/tmp*"\
--exclude="/Network*" --exclude="/Volumes*" \
--exclude="/private/var/run*"\
--exclude="/afs*" --exclude="/automount*" "/." "/Volumes/Backup/"
fi
# End Backup Script


[ Reply to This | # ]
10.4: Use rysnc to perform automatic backups
Authored by: ukkarhu on May 17, '05 04:37:56PM
That's a very valid point - and one I fell for. To include this into my original hints, the code is:

# Local Daily script
# Andrew Padley
#
echo "Starting Daily rsync backup on `date`"
VOLUME="/Volumes/Backup"
if [ -d $VOLUME ]; then
for FSYS in /Users
do
        /usr/bin/rsync -aE --delete $FSYS $VOLUME
        if [ $? != 0 ]; then
                echo " ==> Error during rsync of $FSYS"
        else
                echo "rsync of $FSYS OK on `date`"
        fi
done
else
        echo "==> Backup Volume was not present"
fi
echo "Finished Daily rsync backup at `date`"
Funny thing with rsync is that you seem to need to run it twice to get it to sync properly - something fishy going on here somewhere...!!!

[ Reply to This | # ]
10.4: Use rysnc to perform automatic backups
Authored by: diroussel on May 17, '05 05:51:56PM

Put the backup script on the removable drive, then if it's not connected cron can't run it.



[ Reply to This | # ]