3

I am using rsync to sync a directory from a machine to another but I encountered the following problem: the destination directory permissions are altered.

rsync -ahv defaults/ root@hostname:~/

The problem is that in this case the permissions and ownership of the defaults forlder will be assigned to the destination folder.

I do want to keep the permissions for the files and subdirectories but not for the source directory itself.

Also, I do not want to remove any existing files from the destination (but to update them if needed), but I think that current settings are already ok regarding this.

How can I do this?

1 Answer 1

6

If you want to exclude the defaults directory from having its permissions altered, you would have to literally not include it in the command (since you obviously want to maintain the permissions of everything you are copying). You can thus either do this:

rsync -ahv defaults/* root@hostname:~/

Or, in case you have files or directories starting with a dot inside defaults, and assuming you are using bash:

shopt -s dotglob
rsync -ahv defaults/* root@hostname:~/
1
  • 3
    The downside to this is if you are using something like --delete, rsync won't try to delete remote files that are missing from the source.
    – Danny
    Feb 14, 2017 at 15:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .