Can you pass the chown command during rsync call?

Everything is written in the title.

I see that you can save the owner: group group, but is it possible to change the owner: group in all files on the remote computer after they are synchronized?

Or can you somehow execute an extra command?

rsync -vzrP --delete ~/Sites/website-name/ root@server.com :/home/website-name/public_html/ | chown website-name:websites-group *

Sorry, my rsync / bash knowledge is quite limited.

+6
source share
2 answers

Yes, rsync provides the --usermap and --groupmap to let you configure how they are displayed at the remote end.

In your specific use case, where all files must be mapped to the same list of users / groups, you can use the --chown option, which is a shortcut to the above.

+5
source

In addition to Chris's answer, you can also edit /etc/rsyncd.conf and include uid and gid so that the files get into the corresponding rsync folder.

Example:

 [hadoop_out] comment = hadoop_out path = /mass1/mt_data/hadoop_out read only = no list = yes uid = 26 gid = 26 auth users = postgres secrets file = /etc/rsyncd.secrets hosts allow = 10.11.20.61 

Thus, the files will be synchronized and saved with the uid and gid 26 postgres user, so you will not need to provide this information in the command that you run.

+1
source

Source: https://habr.com/ru/post/976182/


All Articles