0

I am testing whether I use the correct options on rsync because I want to copy a large amount of files from my old server to the new server keeping exact permissions.

On the old server, the file exists like this:

$ ll -n
total 0
-rw-r--r-- 1 1002 1000 0 Jan  9 22:56 testfile

Then I use rsync to copy the file like this:

$ rsync -e ssh -avP . 10.10.10.254:/home/someuser/test
Enter passphrase for key 'newserver.key':
sending incremental file list
./
testfile
           0 100%    0.00kB/s    0:00:00 (xfer#1, to-check=0/2)

sent 125 bytes  received 34 bytes  28.91 bytes/sec
total size is 0  speedup is 0.00

On the new server, there is no user with ID 1002 and no user with the same name. The file is created like this:

$ ll -n
total 0
-rw-r--r-- 1 10001 10001 0 Jan  9 23:56 testfile

I wonder why the file is not created with ID 1002 1000, since the -a (archive) option includes -o (owner), -g (group) and -p (permissions) and the man page says

If a user or group has no name on the source system or it has no match on the destination system, then the numeric ID from the source system is used instead.

Even if I manually add the --numeric-ids switch (which I actually don't want), the result is just

$ ll -n
total 0
-rw-r--r-- 1 10001 1000 0 Jan  9 23:56 testfile

so it has only kept the GID, not the UID

Thomas Weller
  • 4,617
  • 4
  • 24
  • 36

1 Answers1

2

rsync must run with root privileges on the destination machine.

Option 1: enable SSH login for the root user and then specify root@<IP> to login.

Option 2: use rsync with sudo as decribed in this question.

Thomas Weller
  • 4,617
  • 4
  • 24
  • 36