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/apacheconf
date +%F_%T.log -e "ssh -i /home/user/.ssh/id_rsa" /etc/apache2/sites-available --link-dest=/mnt/backup/apache2/apache [email protected]:/mnt/backup/apache2/apache
date +%F_%T.log
Regarding
--update
, the rsync man page is very clear: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
: