[kwlug-disc] if {other command done} then...

John Van Ostrand john at netdirect.ca
Thu Jul 8 11:08:50 EDT 2010


----- Original Message -----
> I push my webserver and desktops each night over to a backup server
> using rsync by running a script on the desktops/webserver. I've got
> that set for 1am.
> Then at about 3 am on the backup server I run a script that compresses
> the backups and dates it.
> 
> Is there an easy way to ensure the script on the backup server doesn't
> start running until the backups are done? Or would I be better forcing
> the compression and dating right from the desktop script?

In-line is easy, if you are using rsync you already have SSH certs to allow cross-server execution:

rsync ..... && ssh root at backup_server "bzip2 /path/to/file"

-- or --

if rsync ......
then
     ssh root at backup_server "bzip2 /path/to/file"
fi

the other way is to use a file as a flag. Have the rsync script set the flag and have the compress check for it "if [ -f flag.file ]; then ...", then remove it before continuing.

e.g.

rsync ..... && ssh root at backup_server "touch /var/run/webserver_bu_flag"

Then on backup server:

if [ ! -f "/var/run/webserver_bu_flag" ]; then
    echo "Error: web server backup not done"
    exit 1
fi

bzip2 .....


-- 
John Van Ostrand 
CTO, co-CEO 
Net Direct Inc. 
564 Weber St. N. Unit 12, Waterloo, ON N2L 5C6 
Ph: 866-883-1172 x5102 
Fx: 519-883-8533 

Linux Solutions / IBM Hardware 




More information about the kwlug-disc_kwlug.org mailing list