I have a script that I call with a cron job to do my nightly backups:
-----------------------------------------------------------------
### Variables set above here ###
$RSYNC -az -e ssh --delete --exclude-from=$EXCLUDE $BACKUP1
[EMAIL PROTECTED]:$DEST >>$LOG 2>>$LOG
mv /path/to/files /new/path/to/files
echo 'Backup to server finished at: '`date` >>$LOG
echo '' >>$LOG
echo '--------------------------------------------------' >>$LOG
echo '' >>$LOG
-----------------------------------------------------------------
It works just fine, until there is a problem with rsync (like the
connection dies, etc.). This is a problem because immediately following
the rsync I move the files being rsync'd.
How can I put a condition around the rsync command so that if it fails,
the move does not run? I assume something like this should do it:
if (rsync command) {
do the move command
}
I just do not know the syntax. I saw a list of "Exit Values" in the rsync
man page but how do I check for those?
Thanks,
Jonathan
/*
PLUG: http://plug.org, #utah on irc.freenode.net
Unsubscribe: http://plug.org/mailman/options/plug
Don't fear the penguin.
*/