Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to backup user files from one server to another with rsync. but I noticed that the user folders change to root. how can I keep the user permissions with rsync (running by root)?

share|improve this question
rsync needs to be run as root when you are making a copy of the drive as well as when you are copying the file back onto the drive. If you do either of the steps as a lower permission user, then root files will be demoted to that user. – Eric Leschinski Jan 3 at 1:00
up vote 21 down vote accepted

Use the -a flag, which includes among other things, the options -o and -g, which preserves owners and groups. This requires that you run rsync as root.

Also, see man rsync.

share|improve this answer

Keeping the permissions is achieved through "archive" mode, -a. The common example is -avz:

rsync -avz foo:src/bar/ /data/bar

This ensures that symbolic links, devices, attributes, permissions, ownerships, etc. are preserved in the transfer. Additionally, compression will be used to reduce the size of data portions of the transfer.

share|improve this answer

If you're using rsync for backup I can really recommend using rsnapshot instead (it uses rsync). It rotates the backups and uses hard links so you can see differences between your daily backups (but folders still look like they have the complete contents). I use this for backing up both Windows and Linux servers at work. Perfect for us!

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.