1

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

6
  • 1
    I would do sudo chown username:username .viminfo (and the other file too), and then retry the original rsync command. There is rarely a good reason for files in your home directory to be owned by root or anyone else.
    – Jos
    Apr 10, 2017 at 10:03
  • What if those file are many? i.e. the output of find /home/diego -group root | wc -l is 2660. I have many files from cloned repos that belongs to root..
    – diegus
    Apr 10, 2017 at 10:23
  • The short answer would be chown -r diego:diego ~ but if you have cloned repo's in there, that might be a good reason to have different owners.
    – Jos
    Apr 10, 2017 at 10:25
  • So in this case , the sudo rsync -av --delete /home/diego ./ can be an option?
    – diegus
    Apr 10, 2017 at 10:54
  • Yes. sudo rsync -av will preserve ownership and permissions.
    – Jos
    Apr 10, 2017 at 11:25

0

You must log in to answer this question.

Browse other questions tagged .