How To Take Secure Remote Backups Using SSH

A couple of weeks back Damien posted an excellent tutorial on securing your internet connection using SSH. In his post, he explains what SSH is as well as the SSH Tunneling method that he uses to secure the internet traffic.

Today, I’ll be taking you through another tutorial that involves using SSH to take backups of your remote servers.

As you guys might be aware that I also run a website called Geeky Ninja which is hosted by the nice folks over at Dreamhost on a Linux server.

Even though Dreamhost keeps a backup of my site, as a webmaster I’m a little paranoid about backups and worry about losing my data all the time. That is why I also backup my site to a remote location occasionally. And this is where SSH comes in.

As you guy probably know that SSH is a secure encrypted protocol to communicate between two machines. Since SSH is not a text based protocol like telnet, it is possible to transfer actually binary files using this protocol and SCP is the utility that accomplishes this task on Unix/Linux based systems. SCP encrypts the files given to it using the SSH protocol and copies it to the remote destination that the user specifies.

Getting Started

First of all you need to make sure that the remote system that you want to copy the data from has ssh installed and running. In my case, that’s the remote webserver hosted at Dreamhost.

Login to the remote system and issue the “pwd” command to see your current directory.


Note down the path that pwd prints. Now, from your local system issue the following scp command.


username with your real username on the remote system,
Remote_IP with the IP Address/Name of the remote system,
Remote_directory with the output of the pwd command from above and
backup_directory with the name of the directory on your local system where you want to store the backups.

That’s it. This command will copy all the files and directories under the remote_directory to the backup_directory on your local system.

Backing Up in Windows

The above instructions will work well for Unix/Linux based machines, but what if you use Windows as your desktop and want to make a backup of your data from the remote machine to your windows desktop ?

Well, in that case you can just use the excellent utility, WinSCP which is a graphical SCP client for Windows


WinSCP gives you the familiar Explorer like interface with full support for drag and drop. Just browse through the directory you want to backup on the right pane and drag it over to the left pane and say GoodBye to text only unsecure FTP sessions.

How do you guys backup your remote servers ? Let us know in the comments.

Image Credit: Carbonnyc


Sharninder is a programmer, blogger and a geek making a living writing software to change the world. His tech blog, Geeky Ninja, is where he shares his wisdom, for free !


  1. I also use Dreamhost but I fell at the first hurdle – logging in to the remote host using the terminal! I run Mac OS X Snow Leopard, I'm guessing the above runs only on Linux?
    Is there something similar for Macs?

  2. the great part about mac is that is it *inx….all you have to do i go into the applications folder and find utilities, and open terminal…..all set…its now as if you were working at the command prompt of a Linux/unix machine.

    I personally prefer to use Rsync. that way only the files which have changed are moved. the command is similar

    % rsync user@host:/path/to/directory /path/to/backup

  3. The procedure is pretty much the same for Macs too. I don't have access to my Mac right now but Mac OS X comes built-in with ssh/scp too. Just open up and try running the commands I've given as is.

    You can also use rsync and follow the procedure that Jolsen has mentioned. I've not used rsync on a mac so can't remember right now if rsync is shipped with the default distribution of OS X or not.

  4. I tried using terminal but got the following message:
    “This account allows only ftp connections”
    I was then logged out!
    I am going to set up a unique IP address with dreamhost to see whether I can then get in via SSH.

  5. That is true. OS X works almost exactly as Linux for this. And I agree rsync is also a great tool for this purpose

  6. Solved! With dreamhost you have set up your user account to allow shell access. Control panel, Manage users, edit, user account type, select shell account and you're done.

Comments are closed.