resume Rsnapshot to same drive

308 Views Asked by At

Sometimes, on a large rsync using Rsnapshot, the NFS mount we are syncing to will drop.

Then when you run:

rnsapshot monthly

to resume it, it will behave as if this is a brand new, rotating the monthly.0 to monthly.1 and so on.

Is there a way to resume the rsync using rsnapshot monthly if something gets interrupted? That won't start a brand new backup?

2

There are 2 best solutions below

0
On

The answer is no not really but sort of. rsnapshot runs as a batch job - generally triggered from a cron job. It does not keep any state between runs apart from the backups themselves. If your NFS mount goes away mid backup, after a while you'll get some sort of IO error, and rsnapshot will give up and die with an error. The backup will fail. Next time it is run after the failure, it will start the backup as if from scratch.

However, if you use the sync_first config option, and not the link_dest option, rsnapshot will do a better job of recovery. It will leave the files its already transferred in place and won't have to transfer them again, but it will have to check again that the source and destination are the same in the usual rsync way. The man page gives some detail on this.

This is not the case with the link_dest method which for most errors removes the work its done and starts again. Specifically, on error link_dest does a "rollback" like this:

ERROR: /usr/bin/rsync returned 255 while processing sam@localhost:..
WARNING: Rolling back "localhost/"
/bin/rm -rf /tmp/rs-test/backups/hourly.0/localhost/
/bin/cp -al /tmp/rs-test/backups/hourly.1/localhost \
    /tmp/rs-test/backups/hourly.0/localhost
touch /tmp/rs-test/backups/hourly.0/
rm -f /tmp/rs-test/rsnapshot-test.lock

If your not using it already, and you can use it (apparently some non UNIX systems can't), use the sync_first method.

0
On

I don't use rsnapshot, but I've written my own equivalent wrapper over rsync [in perl] and I do delta backups, so I've encountered similar problems.

To solve the problem of creating "false whole backups", the basic idea is to do:

while 1
    rsnapshot remote_whatever/tmp

    if (rsnapshot_was_okay) then
        mv remote_whatever/tmp remote_whatever/monthly_whatever
        break
    endif
end

The above mv should be atomic, even over NFS.

I just answered a similar question here: https://serverfault.com/questions/741346/rsync-directory-so-all-changes-appear-atomically/741420#741420 that has more details