rsync --link-dest behaviour when run as sudo
Posted
by
fotNelton
on Server Fault
See other posts from Server Fault
or by fotNelton
Published on 2012-06-25T07:22:50Z
Indexed on
2012/06/25
9:18 UTC
Read the original article
Hit count: 206
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.
© Server Fault or respective owner