How to use rsync to backup over ssh?

rsync is a great tool to back up your work, this is the way I use it the most.

rsync -avz --delete /source/folder user@remote.server:/destination/folder

This way it creates a copy of the /source/folder to the /destination/folder in the remote server, and if a file has been deleted in the source server, it will be deleted from the remote one.

Now, if you want to run rsync over a different por of ssh, (I usually change the port where ssh listens, for security reasons).

rsync -avz -e 'ssh -p 4000' /source/folder user@remote.server:/destination/folder

Change 4000 for the port where you have sshd listening.