rsync not setting stickybit / GID bit

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:


  • 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.)


  • 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?

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)

Asked By: ezekiel


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:

Answered By: meuh

You need to use the -p flag for rysnc.

Answered By: pigfrown

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

Answered By: zodrac
Categories: Answers Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.