14th Jan2013
Author: Gyro

Using rsync to backup a remote folder onto your computer via SSH

I've been having a hard time remembering the correct way of doing this, so I figured I write it down…

Backup the "folder":
# rsync -avz -e ssh user@remotemachine:/some/folder/ /backup/some/folder/

When using a different ssh port (xxxx is the ssh port number):
# rsync -avz -e ‘ssh -p xxxx' user@remotemachine:/some/folder/ /backup/some/folder/

When there is a space in the folder name, you need to put single or double quotes around the folder name:
# rsync -avz -e ssh user@remotemachine:/some/folder/'with a lot of spaces'/ /backup/some/folder/'with a lot of spaces'/

Some cool commands you can add:

--delete
will remove files from the destination folder that are not present in the origin

--progress
shows a nice % progress on the current file

# rsync -avz -e --delete --progress ssh user@remotemachine:/some/folder/'with a lot of spaces'/ /backup/some/folder/'with a lot of spaces'/
This will download the content of the remote folder with a lot of spaces to your local machine with a folder of the same name, while deleting any file that is inside your local folder and not in the remote folder, and it will give you some details to the files being downloaded.

1885

Keep Me Going
Your Name / Website:
Did you like my post? Buy me a Bitcoffee! 14JX52Li7zTKbyQv2omw4tvu6Bi1KzfHNW



Leave a Reply

Your email address will not be published. Required fields are marked *

What is 9 + 4 ?
Please leave these two fields as-is:
IMPORTANT! To be able to proceed, you need to solve the following simple math (so we know that you are a human) :-)