inherit and keep permission destination with rsync

Issues related to applications and software problems and general support
Post Reply
cuongtl
Posts: 5
Joined: 2019/11/27 01:38:23

inherit and keep permission destination with rsync

Post by cuongtl » 2020/06/05 04:37:50

Hi all,
I want to sync from source-folder /data to destination-folder /backup with condition: all files and subfolder after sync will inherit permission from folder /backup.
Anyone can show me a method?

Jean-Pierre
Posts: 7
Joined: 2020/05/31 16:36:25

Re: inherit and keep permission destination with rsync

Post by Jean-Pierre » 2020/06/05 06:42:40

This is probably possible through the use of Posix ACLS :

- mount /backup with option acl
- define the base for inheritance on /backup :

Code: Select all

[linux@optiplex ~]$ sudo mount -o remount,acl /home
[linux@optiplex ~]$ mkdir backup
[linux@optiplex ~]$ setfacl -m 'd:u::rw,d:g::w,d:o::r,d:m::rwx' backup
[linux@optiplex ~]$ getfacl backup
# file: backup
# owner: linux
# group: linux
user::rwx
group::r-x
other::r-x
default:user::rw-
default:group::-w-
default:mask::rwx
default:other::r--
- check

Code: Select all

[linux@optiplex ~]$ cd backup
[linux@optiplex backup]$ umask
0022
[linux@optiplex backup]$ touch file
[linux@optiplex backup]$ ls -l file
-rw-rw-r--+ 1 linux linux 0 Jun  5 08:33 file
[linux@optiplex backup]$ getfacl file
# file: file
# owner: linux
# group: linux
user::rw-
group::-w-
mask::rw-
other::r--
Notes : when acls are in use, the second set of rwx shown by ls is the mask, not the group permissions. Also the umask is ignored, and inheritance does not apply to ownership.

In your situation, you have to make sure the inherited permissions are not overwritten by rsync.

Post Reply

Return to “CentOS 8 - General Support”