I use rsync -a to do a full backup on a file system. Its output to stderr is empty. Shall I do some additional checking to verify if the backup is successful?

For example, how can I do a checksum to verify that?

When I do an incremental backup using rsync next time, will the way of checking by the checksum be the same? The incremental backup will have hard links to the unchanged files in the full backup, and will that make checksums of the source and the incremental backup different although the incremental backup is successful?

My OS is Ubuntu 12.04. Thanks.

  • 2
    What does the documentation say about exit status ?
    – user9517
    Mar 7, 2015 at 22:58

1 Answer 1


If you check the exit code from rsync and it returned 0 (success), no errors should have occurred. In a shell script, immediately after rsync's execution, it would be in $? for bourne-likes and $status for [t]csh. No output on stderr is similarly a good sign, but I trust it less than the exit code.

Depending on the failure, backups using --link-dest may not have had hardlinks created, but doing checksum scans would detect this. If a hardlink is created during rsync, it had already determined that the files are identical and did not transfer the file's data at all. There is no way a hardlinked file would checksum differently in an incremental vs full backup.

If a full backup failed, all of the incrementals based on that full backup are suspect. Generally speaking, rsync is clever enough to figure out differences regardless of full backup completion, and in this case, your subsequent incrementals will be significantly larger than normal. I would still be very concerned about any failure in the backup process.

A word of caution, -c (checksum) will force a full re-read of every selected file on both the source and destination systems, regardless of datestamp or filesize, and will greatly increase the time and system io required on both ends.

edit: To answer your subsequent question, time will pass the return code from its child program through to its parent unless there was an error running time, for example the user SIGTERM'd time.

       The time command returns when the program exits, stops, or is terminated by a
       signal. If the program exited normally, the return value of time is the
       return value of the program it executed and measured. Otherwise, the return
       value is 128 plus the number of the signal which caused the program to stop
       or terminate.
  • Thanks. (1) I didn't check $? and now I think I may have lost the chance to do that because I ran other programs following rsync? (2) Is it possible to run rsync and store its exit code in a variable in bash?
    – Tim
    Mar 7, 2015 at 23:37
  • 1
    that's beyond the scope of serverfault, but yes, $? is just a special variable. You can store it like any other value: NEWVARIABLE=$? Mar 7, 2015 at 23:41
  • I updated my answer with the information you requested, but you're starting to leave the scope of your original question. Check the manpages for commands you're trying to use, they are very informative. Mar 9, 2015 at 14:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.