The Samba-Bugzilla – Bug 8973
--delete or similar (--delete-after / --delete-before) does not work if used after --rsh
Last modified: 2012-06-16 17:13:10 UTC
rsync -avzie --delete --rsh="ssh -p 1234 -i /home/username/.ssh/user-rsync-key" firstname.lastname@example.org:/var/www/ /media/Files/Backups/rsync/www/
This will copy, and update files as expected, however will not delete the files on the local machine if they no longer exist on the remote.
However, by moving the --delete to after the --rsh command, local files are deleted as expected...
rsync -avzie --rsh="ssh -p 1234 -i /home/username/.ssh/user-rsync-key" --delete email@example.com:/var/www/ /media/Files/Backups/rsync/www/
The -e option is an alias for --rsh, so your first command says your remote-shell command is "--delete", and it is then changed by the repeated --rsh option. Drop the "e" from the "-avzie" list, and you'll be fine.