Dreamhost Backup Rsync

Save With Dreamhost Promo Code

Backup Your Personal Computer to Dreamhost with Rsync

As I have mentioned in my Dreamhost Backup article, Dreamhost encourages you to back up your own websites and develop your own systems to do so.

If you are familiar with Rsync (probably so if you are reading this)’ but if not Rsync is a unix program that provides the fastest way to back up files espeically when you run Rsync multiple times. Rsync only backs up what is changed.

Anyways, its a great program for backups and here is a tutorial that will show you how to automatically backup your personal computer to Dreamhost’s personal backkup area. This is for windows but you can follow along and adapt it to Mac OSx.

Installing Rsync on your Computer

To get started you will need a program called cwrsync.   Click here and download cwrysnc from sourceforge.  Afterwards install cwRsync , now if you are following along on a Mac or Unix platform there is nothing to do, these programs should already be installed.

Next, it’s time to configure your server on backup.dreamhost.com.

Click here to save $50 with Dreamhost Coupon BEKIND

Initial Remote Server Configuration

Now lets get the server ready to work with cwRsync. I am using a server here on Dreamhost as an example. Using an SSH client connect to your server and run these commands:

[cc lang=”bash” width=”600″ height=”100″]
cd $HOME
mkdir .ssh
cd .ssh
touch authorized_keys
chmod go-w $HOME $HOME/.ssh $HOME/.ssh/authorized_keys
Now, if you are doing the backup to your personal backup space on Dreamhost, you will not be able to login via SSH so instead you will have to use sftp to connect to your backup account and then create a directory called .ssh. IMPORTANT – File permissions need to be correct for rsync(or any automated login) to work correctly. File permissions need to be restricted.

Per the script above, you will need to execute the command chmod go-w on your home directory, your home/.ssh directory and the home/.ssh/authorized_keys file itself – what this means is to take away write permissions for that directory. Fortunately, If you are using filezilla SFTP (recommended and free) then it’s easy to do. Pictured below  — >uncheck the Write boxes.


The goal is to automate your backups and make them password less.  You will need to remember what your directory is called so be sure to write the directory name — In our example we have: /home/rsynced/.ssh

Our server is now configured and ready now we need to setup our local computer.

Initial Local Computer Configuration

On your local computer create a directory called temp on the C drive which will be used for test uploads. Next go to where the cwRsync program was installed and edit the file called cwrsync.cmd. If you are in windows vista, you might have to right click and run notepad as an administrator.  Anyways, append the line below to the cwrsync.cmd file and then run the cwrsync.cmd. The screenshot below is slightly different but you will get the idea.

[cc lang=”bash” width=”600″ height=”10″]
ssh-keygen -t rsa


You will have created two files, a private key file and public key file. The private key should always be secure on your computer and the public key file (located in your /users/name/.ssh/id_rsa.pub) will need to be put on a new line in the authorized_keys file mentioned above.

If your authorized_keys file has not been created upload id_rsa.pub and rename it to authorized_keys (Remember, as noted before, to remove write permissions on authorized_keys or the whole thing won’t work )

Almost There – Final Upload Test !

Change this script below so that it is suited to your needs. If you have follow along exactly then you would just need to change the username b113579 and the directory path /vol/raid3136/b113579/

[cc lang=”bash” width=”600″ height=”10″]
rsync -avrz –progress “/cygdrive/c/temp” b113579@backup.dreamhost.com:/vol/raid3136/b113579/

Rsync Without A Password

Now rysnc should be working automatically without a password.  If not and its prompting you for a password  , don’t worry, you are almost there ; You will need to make sure that the authorized_keys file has your public key typically named id_rsa.pub in a .ssh directory under your home directory and that all your permissions for files related to .ssh both files and folder do not have write permissions – we’ll only for the owner – see the screenshot above of the ftp program.

Final Testing

Now lets try backing up a folder – in this example the temp directory we created –  c:\temp

Here is the command: (you should see how to modify if your own use now) but append this to the cwrsync.cmd file we have been working with.

[cc lang=”bash” width=”600″ height=”10″]
rsync -avrz –progress “/cygdrive/c/temp”  b113579@backup.dreamhost.com:/vol/raid3136/b113579/

Automating Daily Backups

Now to automate this backup so that it happens daily in windows – its pretty simple just take the script (cwrsync.cmd file)  and set it up to run with Windows automated task scheduler.

I am not going to explain this because if you have followed along so far then this part is going to be easy but briefly , under Accessories > System Tools in Windows there is a Schedule Tasks program. Open this folder and start a new task. (Note: you will need to schedule this as the same user who created the RSA key.)

Remember your initial backup will take a long time but subsequent backups with be rapid as only the changes in a file are sent to the file server.  Also,the progress switch –progress will show you that it is actually working and you can watch the transfer rate and all that

Final Considerations

  • If this is all way too complicated – you might want to signup with an online backup service like Mozy.
  • You can apply this tutorial to backup between Internet webhosts
  • A good resource on Rsync is http://rsync.samba.org/ftp/rsync/rsync.html
  • If you want to backup from multiple machines, you’ll need to create an authorized_keys file that contains all of the public keys, and then upload that. You are not able to cat new keys onto the existing file, however you can open them manually and append them using a good text editor like notepad ++