Using rsync for Plone directory copy

I'm running a zeo instance of Plone 5.1. I want to copy the ./Plone directory from my server and put it on a local VM for testing. If I rsync it to a local directory (my site is shut down), since I don't have plone_buildout / plone_group on my local machine, the Plone directory and all sub-dir & files are not properly owned (1004 and 1003 as user/group). For this process to work, should I add this user and this group to my local system? I'm asking both for the practical reason of making this work, and also as I want to understand.

Thanks,
David

You need ˋrsync -az source destˋ and of course you need to run this as roo.

-aj

Thanks Andreas for the reply,
I did:

sudo rsync -azv -e ssh root@x.y.z.org:/usr/local/Plone /my/backup/folder/

which I believe is in essence what you were saying. Then, when looking into /my/backup/folder/:

$ ls -la '/my/backup/folder/Plone/buildout-cache/' 
total 72
drwxr-xr-x   4 1004 1003  4096 Mar  8  2011 .
drwxr-sr-x   5 1004 1003  4096 Dec 24  2016 ..
drwxr-xr-x   3 1004 1003  4096 Apr 12  2015 downloads
drwxr-xr-x 901 1004 1003 61440 Apr 16 20:09 eggs

Is this right? It seems that original ownership info is not present. What am I missing?
Thanks,
David

I assume related users and groups must exist on the target system with the same user ids and group ids.

Ah, so, I'm guessing it's not possible to use rsync to copy over the files and keep their ownership info intact if the same users aren't on the destination system. That was my original question.

OK, I've got a few ideas how to solve this, but to decide the best one for my situation, I need to know if there might be a problem if, for example:

My current plone server has a:

username of plone_buildout w/uid of 1004

but my backup machine has a

username of plone_buildout w/uid of 1005

And say furthermore my experimental setup VM has a:

username of plone_buildout w/uid of 1006

Might this be OK or more likely a problem?
Thanks,
David

@dgroos Doing a bit of googling can help you with that, this is not Plone specific but system administration related:

Hi Fred, my thinking of the problem wasn't framed like that, Thanks!

So as per that page I ran a test which looked like it worked:

sudo rsync -azv -e ssh root@x.y.z:/usr/local/Plone/Plone-docs /my/test/folder/Plone-docs/ --usermap=1004:1000,plone_buildout:me --groupmap=1003:1000,plone_group:me

Source directory on server:

me@server:/usr/local/Plone$ ls -la /usr/local/Plone/Plone-docs/
total 48
drwxr-sr-x 2 plone_buildout plone_group  4096 Oct 14  2015 .
drwxr-sr-x 5 plone_buildout plone_group  4096 Dec 24  2016 ..
-rw-r--r-- 1 plone_buildout plone_group  3013 Oct 14  2015 CHANGES.rst
-rw-r--r-- 1 plone_buildout plone_group  6320 Oct 14  2015 CREDITS.txt
-rw-r--r-- 1 plone_buildout plone_group 15220 Oct 14  2015 LICENSE.GPL
-rw-r--r-- 1 plone_buildout plone_group   667 Oct 14  2015 LICENSE.txt
-rw-r--r-- 1 plone_buildout plone_group  2070 Oct 14  2015 LICENSE.ZPL
-rw-r--r-- 1 plone_buildout plone_group  1493 Oct 14  2015 UPGRADE.txt

Target directory on my home backup computer:

me@home:~/$ ls -la  /my/test/folder/Plone-docs/
total 48
drwxr-sr-x 2 me me  4096 Oct 14  2015 .
drwxr-xr-x 3 root   root    4096 Jul 16 14:22 ..
-rw-r--r-- 1 me me  3013 Oct 14  2015 CHANGES.rst
-rw-r--r-- 1 me me  6320 Oct 14  2015 CREDITS.txt
-rw-r--r-- 1 me me 15220 Oct 14  2015 LICENSE.GPL
-rw-r--r-- 1 me me   667 Oct 14  2015 LICENSE.txt
-rw-r--r-- 1 me me  2070 Oct 14  2015 LICENSE.ZPL
-rw-r--r-- 1 me me  1493 Oct 14  2015 UPGRADE.txt

[looks like everything worked but this line is different, does it matter?

drwxr-xr-x 3 root   root    4096 Jul 16 14:22 ..

So, my idea is to add the following 2 users and 1 group with the following attributes (from my plone server) to the VM on which I'm going to be running the testing:

me@server:~$ cat /etc/passwd | grep plone_
plone_daemon:x:1003:1003::/bin/false:/usr/sbin/nologin
plone_buildout:x:1004:1003::/bin/false:/usr/sbin/nologin

me@server:~$ cat /etc/group | grep plone_
plone_group:x:1003:plone_daemon,plone_buildout

And then I can just use the --usermap and --groupmap functions of rsync to appropriately map this info on each transfer (from server to backup machine and then from backup machine to testing VM).

Do you agree? Can I just make the plone_buildout user with the attributes shown above or should I use the unified Plone installer that will auto-create the users/group with correct attributes? Again, looking to understand not just solve.