I have a movable hard-drive that I would like to use to backup my data using rsync command. To accomplish that I would navigate to the directory of my external hard-drive (target directory) and run:
rsync -av --delete /home/diego ./
While running I get few failures, for examaple:
rsync: send_files failed to open "/home/diego/.viminfo": Permission denied (13)
rsync: send_files failed to open "/home/diego/pfsense.img": Permission denied (13)
Now, those file are owned by root in my home directory. My question is what should I use to fix that:
1) The over-mentioned command with sudo:
sudo rsync -av --delete /home/diego ./
2) The switch used for ssh
rsync -av --rsync-path="sudo rsync" --delete /home/diego ./
3) Something else
and what is the difference between 1) and 2) ? thanks
sudo chown username:username .viminfo
(and the other file too), and then retry the originalrsync
command. There is rarely a good reason for files in your home directory to be owned by root or anyone else.find /home/diego -group root | wc -l
is 2660. I have many files from cloned repos that belongs to root..chown -r diego:diego ~
but if you have cloned repo's in there, that might be a good reason to have different owners.sudo rsync -av --delete /home/diego ./
can be an option?sudo rsync -av
will preserve ownership and permissions.