1

Using the following rsync command, the RWX permissions are being correctly set for both files and directories but the sticky bit options are not.

rsync -rtvz --partial-dir=.rsync-partial --chmod=Da+t,Dg+s,D770,F0740 --progress --stats -e 'ssh -p 19419' "/home/me/test_dir" me@REMOTE_HOST:~

I understand that the options should act as below:

Da+t

  • all dirs should have sticky bit set (only the root user, the owner of the directory, and the owner of a file can remove files within said directory.)

Dg+s

  • all dirs should have setGID (all files created within said directory inherit the group ownership of that directory)

but sticky bits and setGID bits are not set on the REMOTE_HOST dirs with the above command.

If I ssh to the REMOTE_HOST and run something like chmod -R a+t test_dir then the sticky bits will be set as expected.

Where am I going wrong?

Edit: I also separately tried just "--chmod=Da+t,Dg+s", "--chmod=Da+t" "--chmod=Dg+s" "--chmod=a+t" and no sticky bits are set with any of these options.

(Ubuntu 16.04, rsync 3.1.1 - I took the chmod options straight from the man page)

ezekiel
  • 167
  • 6

3 Answers3

0

The modes are applied in the order given. This means the later D770 option overrides any earlier modes to set the directory to exactly 770. Change the order to:

--chmod=D770,F0740,Da+t,Dg+s
meuh
  • 49,672
  • 2
  • 52
  • 114
  • hi, thanks for reply! Unfortunately this hasn't made any difference. I should have noted that I tried ordering the options differently. I just tried the specific ordering you suggest here. I also separetely tried just "--chmod=Da+t,Dg+s", "--chmod=Da+t" "--chmod=Dg+s" and no sticky bits are set. – ezekiel Nov 11 '20 at 09:32
0

You need to use the -p flag for rysnc.

pigfrown
  • 18
  • 1
0

I had the same problem: "rsync not preserving setgid of parent destination". The command I was using was something like:

rsync -zrvhtl <source> <destination>

On destination only files and folders from the root source was set to correct group, but synced folders was not given the g+s so all files and folders down had the source group. When running the command like in man example and only adding -r option it worked

rsync --no-p --no-g --chmod=ugo=rwX <source> <destination>

Adding one option at time found out the -t is having this efect (resting setgid) on destinations folders. To overcome this I added -O

-O, --omit-dir-times This tells rsync to omit directories when it is preserving modification times

zodrac
  • 1