Ownership and permissions when syncing directory contents
John Lane
rsync at jelmail.com
Fri Jan 20 10:13:12 UTC 2017
When you rsync a directory, say `$rsync mydir/ ...` with the trailing
slash, the destination directory is changed to the ownership,
permissions and timestamp of `mydir`.
Consider this simple example
$ mkdir test
$ cd test
$ mkdir a b
$ touch -d '01 jan 1980' a/A
$ touch -d '15 jun 1985' a
$ touch -d '02 feb 1990' b/B
$ touch -d '25 aug 1995' b
$ mkdir c
Note the directory 'c' timestamp:
$ ls -ld c
drwxr-xr-x 2 john users 4096 Jan 7 20:50 c
Now, rsync:
$ rsync -a a/ b/ c
$ ls -ld c
drwxr-xr-x 2 john users 4096 Jun 15 1985 c
The directory 'c' now has the timestamp of the file 'a'
Furthermore, if the copy is done with root, the ownership and
permissions of the file are also propagated to the directory. Note the
destination directory gains the properties of the first source directory
with a trailing slash.
I am using:
rsync version 3.1.2 protocol version 31
Linux 4.8.13-1-ARCH #1 SMP PREEMPT Fri Dec 9 07:24:34 CET 2016 x86_64
GNU/Linux
Am I using it correctly, or is this a bug or is it expected behaviour ?
More information about the rsync
mailing list