2

I have a command which looks like this:

rsync -avp -e ssh /folder user@server:/backups/2 --link-dest=../1 Folder number increases every day.

This command runs every night, over my very very slow internet connection. If it did not complete during the night, the process will be killed because otherwise my connection is unusable during the day. This would work fine, if Rsync starts with creating hard-links, and then does the data-transfer.

Unfortunately, it looks like Rsync performs its tasks on alphabetical order. So sometimes it starts with transferring data and then afterwards it will create its hard links.

If the process does not complete overnight, it needs to upload even more data the next night, because the hardlinks were not created in folder 2!

Is there a way to make Rsync create the hard links first and then do the filetransfers?

Thanks a lot!

6
  • You would do better to get an Internet connection that actually meets your needs. May 8, 2018 at 20:46
  • Then I would need to move, and I live in an amazing place! Well... apart from the internet connection
    – Joel'-'
    May 8, 2018 at 20:49
  • Seriously, if you can't complete a backup over the Internet connection in the time you have available to run the backup, nothing will help except getting more bandwidth or more time. You cannot change the laws of physics! May 8, 2018 at 20:55
  • 1
    This for a backup? You may want to look at something like borg/attic instead. This tools do work do a far amount of work to minimize data transferred. Caches of the crypto hashes of the transferred chunks are stored on the 'client' side so that only changes are transferred.
    – Zoredache
    May 8, 2018 at 21:12
  • @MichaelHampton I think this is not true. The entire backup does not need to complete in 1 night. It can just continue in folder 3, based on the information it already had in folder 2. The backup will just be a bit behind. The only limit is that we should not be changing more files than the connection can handle EVERY day. Because then the backlog will grow larger and larger.
    – Joel'-'
    May 9, 2018 at 8:01

2 Answers 2

3

The answer is to add --delay-updates. This causes Rsync to build a list of all changes first. The target will then create all the hard links and create all folders. After that, the datatransfer will start.

rsync -avp --delay-updates -e ssh /folder user@server:/backups/2 --link-dest=../1

1

The --link-dest=../1 number should point to the most recent successful backup, not the most recent attempt.

Or, better yet, use multiple --link-dest flags, one for the most recent success, then additional ones for any failed attempts since the most recent success.

Quoting the man page:

Beginning in version 2.6.4, multiple --link-dest directories may
be provided, which will cause rsync to search the  list  in  the
order  specified  for  an exact match.

Combine this with --delay-updates (as Joel suggested) and you'll have a fairly robust system.

However as long as you have very limited bandwidth, your problems are only going to get worse over time as your data needs grow. I was in a situation like this once. The rsync just barely finished over night. A few weeks later it wasn't finishing with 24 hours. Since it was a daily since, you can see the problem! It might catch up over the weekend, but soon that wasn't enough. Eventually I just had to find a way to get more bandwidth.

If you are going to use this in a production system, I recommend that you log how many failures there are, and how many "failures since last success". Set up monitoring to collect this data and alert if the "failures since last success" grows to an unacceptable number (2? 5? It depends on your needs).

1
  • Thanks! It's regarding my home NAS which I want to have backed up to my old home nas, which now lives in a different house. The link-dest must always point to the latest one. Otherwise, the data transfered the night before is disregarded with the next transfer, if it did not complete in time. Multiple link-dests is a great idea!
    – Joel'-'
    May 10, 2018 at 15:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .