What I couldn't figure out is how to sync local files to remote host, while leaving remote folder permissions for a particular folder /var/www/site1/home/images intact, which is 750, while source folder permissions are 770. I need this folder apache-writable locally, but it shouldn't be writable on production server. And I need to keep target permissons only for this folder, for all other files and folders perms must be updated.
Thus far I was experimenting with --exclude, -filter but didn't get the desired effect.
rsync -av --delete /var/www/site1/ [email protected]:/var/www/site1/
Amongst many other options rsync can change permission by running it with the option: rsync [options] --chmod=CHMOD source destination where you can also combine option --archive with the option --no-owner or --no-perms to exclude preservation of owner resp. permissions.
The answer is wrong, rsync won't create directories automatically if target folders don't exist. Sigh. I strongly suggest readers to check the manpage for --relative. It might not do what you think. --relative sticks the full path, rather than the file, at the endpoint you provide on the server.
Rsync directory with the “-r” option: For direct syncing, utilize the recursive “-r” option in the rsync command. The below-given syntax will sync the content from the source to its destination directory. The “/” points towards the content of the source directory.
-o, --owner This option causes rsync to set the owner of the destination file to be the same as the source file, but only if the receiving rsync is being run as the super-user (see also the --super and --fake-super options).
From the rsync man page: -a archive mode; same as -rlptgoD
.
-p
is preserve permissions, so this should do what you want: -vrltgoD
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With