Firstly, I have a hard time understanding what the --update parameter does. I thought that without it, it would logically update any file that changes and I believe that's what it does, so why does the --update parameter even exist?

Secondly, related to what I asked because I thought it would solve my issue, but it doesn't, I have a bunch of config files that I would want updated into a different folder every time they change by having a cronjob that runs the below command every hour or every day, this way I can have a few previous versions in case something goes awry. The problem is that these files rarely change, but rsync creates another folder with hard links regardless it changes or not, which is a bit annoying because then you have loads of folders of the same thing, even them being a hard link and not taking space, it creates a lot of clutter.

Isn't there any way to stop rsync --link-dest from doing this? That is, create the folder only if anything changes, otherwise do nothing. Seems like a pretty basic case scenario so I would have thought there is an easy way to do this with a parameter, but I can't find the answer anywhere.

rsync -azP --delete --stats --update --log-file=/var/log/rsync/apacheconfdate +%F_%T.log -e "ssh -i /home/user/.ssh/id_rsa" /etc/apache2/sites-available --link-dest=/mnt/backup/apache2/apache user@xxx.xxx.xxx:/mnt/backup/apache2/apachedate +%F_%T.log


Regarding --update, the rsync man page is very clear:

-u, --update: skip files that are newer on the receiver. This forces rsync to skip any files which exist on the destination and have a modified time that is newer than the source file. (If an existing destination file has a modification time equal to the source file's, it will be updated if the sizes are different.)

Without this option, an old file on src can overwrite a newer file on dst. Using this option, you are sure that newer files are never overwritten by older version.

For your second problem, simply avoid using --link-desk. The entire point of this option is to have a complete directory/file tree without have to pay the space of a true, full copy. If you don't want a complete tree each time, but you only want to see the changed files/dirs, avoid using --link-desk

Moreover, for added efficiency in the file transfer process, you may use --compare-dest:

--compare-dest=DIR This option instructs rsync to use DIR on the destination machine as an additional hierarchy to compare destination files against doing transfers (if the files are missing in the destination directory). If a file is found in DIR that is identical to the sender's file, the file will NOT be transferred to the destination directory. This is useful for creating a sparse backup of just files that have changed from an earlier backup.

  • Thank you Shodanshok, I got the --update, your two lines explained it better than the man page in my opinion ;-) – Ulukai Jan 8 '16 at 8:42
  • Regarding the --compare-dest. That looks like it creates another directory with only the different files. That's not what I want, as I that would mean playing lego with different directories when you have to do a restore. I love the --link-dest parameter and the idea of hard links to save space, but I think is so useless that it creates an entire new directory even if all the files are the same, I just wish there was a way to stop this? – Ulukai Jan 8 '16 at 8:46
  • Point is, I want the entire directory/file tree. But I don't want it repeated a hundred times if there are zero changes between all of them. – Ulukai Jan 8 '16 at 8:50
  • So if a file change in one directory, you want the entire directory (and only it) to be present in the new backup? I don't think rsync supports this kind of operation. After all, if you want the entire directory tree, you inevitably will have it repeated even if no changes happened. This is why --link-desk is so valuable: you will have complete point in time restores available. Don't bother with the number of hardlinks: EXT4 and XFS can easily manage them. – shodanshok Jan 8 '16 at 10:18
  • If a file changes I want the entire tree,to be recreated with links as it normally does, but otherwise don't create a new one. Yeah I know the file system can take it, it just looks messy. I basically have the backup running once an hour, other directories in my script change often and it makes sense, for folders with config files it's different because they rarely change, so I would have 800 versions of the same thing. I still think this would be really a good feature if implemented. Otherwise great tool! – Ulukai Jan 8 '16 at 20:42

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.