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?
inherit and keep permission destination with rsync
-
- Posts: 12
- Joined: 2020/05/31 16:36:25
Re: inherit and keep permission destination with rsync
This is probably possible through the use of Posix ACLS :
- mount /backup with option acl
- define the base for inheritance on /backup :
- check
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.
- 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--
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--
In your situation, you have to make sure the inherited permissions are not overwritten by rsync.