4

I have an nfs device that creates checkpoint (backups) everyday. I want to use Rsync to copy these checkpoints to another device (Drobo connected via iSCSI). So I've run the script on a single nfs share and it works nicely. Here are a couple concerns I have that will take too long to experiment with multiple times.

  1. There are multiple shares to back up, and I would like to loop through them and run the script over each one. How will this work with Rsync? Will the Rsync job start and then loop again and run a second and third and fourth Rsync job simultaneously, or will Rsync wait for the job to finish before ending and restarting the loop? Maybe I just need to put some check in the loop to not restart until Rsync is done.

  2. Referring to that last sentence; what does Rsync return that I could use to report if there was an error or continue the loop if all went well?

  3. The checkpoints created by the NFS device are named based on the date. Rsync is unpacking the .ckpt* file into a statically named directory. Since the source is a different directory but the files inside are the same, and the target is named the same, will Rsync still only copy the differences?

this is the rsync job: rsync -az $NEWCHKPT/* /drobo/bak.${share}/${share}_daily

I know this is post is asking alot. Any advice is greatly appreciated.

Dan
  • 6,753
  • 5
  • 26
  • 43

1 Answers1

2
  1. Depends on how you write the loop; unless you background the rsync commands with the & symbol, the rsync commands will run in sequence.

  2. rsync will return a useful exit status. These are listed in rsync's manual page. man rsync | less '+/^EXIT VALUE'. You have to decide whether you want to abort the whole script when one fails, or attempt to run the others, then provide an error summary at the end for the ones that failed.

  3. rsync has various ways to decide whether to copy a file or not. The default is to check the size and last modification time of the source and destination files. If both match, it skips copying that file. That's usually good enough.

geirha
  • 46,101
  • Thanks, that is some helpful information. I know Rsync has some helpful return values. I guess what I should have asked is; How can I get a hold of those values in my script? Like what variable do I need to check after the rsync job? – Dan May 15 '13 at 16:44
  • @dan08 If you only care whether it succeeded or not, you use if rsync ...; then echo "rsync succeeded"; else echo "rsync failed"; fi. If you want to distinguish between the different types of failures, you want to copy the ? parameter right after the rsync command. rsync ...; status=$?; if (( status == 11 )); then echo "bla bla"; elif (( status == 12 )); then echo "other bla"; fi – geirha May 15 '13 at 16:51
  • Yes, the latter is exactly what I want. Thanks. – Dan May 15 '13 at 17:27
  • If geirha's answer solved your problem, don't for get to "accept" the answer. +25 points to geirha, +2 to you. – Argusvision May 17 '13 at 17:13