Question : Keep file ownership when using Rsync

I am currently setting up a backup solution using Rsync to our NAS box however I am having a problem getting the owner and group to be preserved on the NAS box. I am running the Rsync job as root and using the -o and -g options however all of the files appear to be owned by the user I am logging into the Nas with. Is there any way I can get the ownerships to be preserved as in the case of a restore it will save me a lot of valuable time.

My current command is:
rsync -av -o -g --bwlimit=6000 -e ssh [email protected]:/backup/daily --backup --backup-dir=/backup/daily/`date +%Y-%m-%d`


Answer : Keep file ownership when using Rsync

I should have spotted this one first time around... If the user in "[email protected]" is not root, then rsync will not be able to change ownership. Only root can set the ownership of a file or directory to another user.

Note that in order to log in, you may have to change 'PermitRootLogin no' to 'PermitRootLogin yes' in sshd_config, if you have that option set.

Random Solutions  
programming4us programming4us