rsync --link-dest behaviour when run as sudo
- by fotNelton
In order to create regular backups, I'm using rsync together with --link-dest so as to create hard-links for unchanged files. For example:
rsync -ax \
--partial --delete --delete-excluded --inplace \
--exclude-from=/tmp/temp_excludes \
--link-dest=/Volumes/Backup/current \
/Users /Volumes/Backup/2012-06-25
This works very well as long as I start the process from my normal user account. Though as soon as I start the process using sudo it behaves erradically, meaning that rsync copies all the unchanged files instead of hard-linking them.
Since sudo modifies the environment, I've already also tried sudo -E in conjunction with making sure that my sudoers file has the corresponding option set. Well, that didn't work either.
So, the question is, how can I run rsync using sudo? Whereas the above example only shows a backup of the Users directory, I also need to backup some system files that I can only access as root.