How To: Backup your Mac to a Dreamhost Server (part 1 of 2)

Time: Two 30 minute session, with a break between.
Geek Level: Played Dungeons and Dragons, but didn’t own your own dice.
Written for: Mac OSX 10.4.8 (should work on OS 10.2 and up), Dreamhost server account

Ever since my complete meltdown at the beginning of the year, I’ve been like a backup zealot. All of my computers are now on a regular back-up rotation with SuperDuper, and I’ve built an automated off-site backup plan too. This post will walk you through how to build an off-site backup of your data.

Some background

With so many companies offering website hosting, providers have started to compete on both price and storage space. Dreamhost has a plan that offers 170 GB of server space for $8 a month. For just a second, don’t think about that as a website server, think of it as a hard drive that you can rent for $8 a month, only this hard drive is maintained by somebody else, and they keep a backup copy of everything on it, so that if it crashes, your data gets completely restored. As a bonus, this extra hard drive you’re renting from Dreamhost keeps growing in size by 1 gig every week. Even if you’re not planning on building a website, that kind of cheap storage space is well worth the money.

There are two huge advantages to off-site backup on a server. First, if something catastrophic happens, like a fire or theft, I need to have my critical files stored in some other location. Secondly, this enables me to access those critical files from any computer, anywhere. I don’t need to worry about bringing my lecture notes to class with me – I can access them on the server when I get there.

So, I’ve decided to use the extra storage space on my Dreamhost account to keep regular backups of all my critical data. I keep a copy of my Documents folder on my Mac synced to the server, as well as a full copy of my audio hard drive, and all of my samples. Today, I’ll show you how to setup the same backup system I use, and how to automate it so that it backs up your data even if you forget.

(Note: Dreamhost doesn’t allow you to keep pirated media on their servers. If you have a ton of BitTorrent movies and TV shows on your computer, and you sync them up to the server, you’ll get a friendly little email from Dreamhost asking you to take them down)

This tutorial has a pretty high geek rating – it requires you to use some programs you might not be familiar with, like Terminal, and the Applescript Editor. It’s written to be understood by casual computer users, so here’s the deal – I’ll gladly offer personalized tech support to anyone who opens a new Dreamhost account using this link: Dreamhost Signup. I get a little kick-back from them if you do, which in turn makes me a happy little tech-support guy. If you sign up for a new account, I’ll work with you to get this working right.

The Plan

  1. Signup for a Dreamhost Account
  2. Create a new user with SSH login
  3. Using shared keys, enable SSH access to the server without having to supply a password
  4. Run rsync from the terminal to create a back-up of your home folder on the server
  5. Create an applescript that runs rsync automatically
  6. Use iCal to run the applescript backup daily, without doing a thing!

Before we begin, please do a local backup of your computer to an external drive, using SuperDuper or some other applications. We’re not doing anything here that will break your computer if you follow the directions, but it’s always a good idea to backup before you do anything new to your system.

1. Signup for a Dreamhost Account

Ready? Click here. Pick whichever plan works for you – the basic plan is probably enough for most people. Sweet! You’re already 1/6th of the way done!

2. Create a new user with SSH login

When you created your new Dreamhost account, you created a default admin user. The first thing we’re going to do is add another new user that will only be used for backups. Think of users as separate drawers in a filing cabinet. Your account can have a bunch of users, each with their own drawer. Each drawer has its own separate login and password. This way, your backup data stays separate from any data you’re using for a website.

Dreamhost will send you an email with details about your new account. There are a few things you need to write down and keep handy. First, it will tell you which server your account is on. It will be something like Whenever this tutorial uses the word SERVER, replace it with the info from that email.

add userNext, the email will give you details on how to access the control panel for your hosting plan. Login, and look for the “Users” tab on the left sidebar menu. Then, click “add a new user”.

When the new page loads, under “Type of User Account” select shell. This will allow you to login directly to your server and pass files back and forth.

ssh account

Write down your user name and password. Again, whenever this tutorial uses the words USER or PASSWORD, replace them with the user name and password you’ve just created.

It’ll take 10 minutes or so for Dreamhost to get the new user up and running, so now would be a good time to brew some coffee and put on The Dailies CD.

3. Using shared keys, enable SSH access to the server without having to supply a password

Ok, ready? It’s about to get very geeky. Don’t be scared. Most of you think of computer applications as graphic windows that you click in and drag things around in (think iTunes). Those aren’t really the applications – they just control the applications. The applications are running under the hood. In the next few steps, we’re going to use some applications that don’t have graphic interfaces – you operate them by typing commands, which the application then carries out. That’s the only difference. Don’t let it scare you. If it makes you feel more comfortable, just copy and paste the text that’s here, and only change things like the SERVER, USER or PASSWORD.

Launch the “Terminal” application. It’s in your Applications folder, inside a folder called “Utilities”. Whoah! Check that out! Your geek rating just went up 4 points.

You’re going to enter some text commands into the terminal. You should see a string of text in the window, followed by a $ dollar sign (called a command prompt). Type the commands after that $. You can simply copy and paste what’s here, remembering to replace SERVER, USER and PASSWORD with your own info.

Let’s make sure the SSH login to your account is working. Type the following:


You will get a warning saying that the authenticity of the host can’t be verified. Type “yes”. Next, you will be prompted for your password. Type it, and hit enter. Congratulations, you are now connected to your new server! Now type “exit” to close the connection.

In order for our automatic backup to work, we need to be able to connect to the server without having to enter in the password each time. Rather than retype the whole article, let me point you to the Dreamhost support wiki article. It’s pretty clear, just type in the commands as they appear. Replace in their tutorial with your SERVER info, and you’ll be fine. To see if it worked correctly, exit out of your server, then type


This time, it should connect you without asking for a password. Sweet!

4. Run rsync from the terminal to create a back-up of your home folder on the server

Ok, now we’re ready to do the first major backup of your data. We’re going to use an application called “rsync” to do that backup. Rsync doesn’t have a graphic interface, it runs from the terminal. It’s job is to compare two different files or folders, called a SOURCE and a DESTINATION, and to make changes to the destination. The advantage of rsync is that it only sends that data that needs to be changed, which makes our backup much quicker. Enter the following into the terminal, all on one line (don’t worry if it automatically makes line breaks for you, just don’t hit return until you’ve entered the whole thing)

rsync -avz ~/Documents/ USER@SERVER:~/laptop.bak/Documents/

Here’s what you told it to do:

  • “rsync” tells the terminal which program to use
  • “-avz” tells rsync which settings to use. This set of letters tells it to preserve some important information about the file permissions, and also tells it to compress the data so that it requires less bandwidth over your network connection.
  • “~/Documents/” gives rsync the SOURCE it should look at. In this case, it’s gathering data from the Documents folder in your user account. If you want to backup your entire account, replace this with just “~/”, and do the same to the following step.
  • Finally, “USER@SERVER:~/laptop.bak/Documents/” tells rsync where to put the files. USER@SERVER should look familiar – it’s the login to your dreamhost account. The last part of the command, “:~/laptop.bak/Documents/” creates a new folder on your server, called “laptop.bak”. Since I’m backing up many different computers, this helps me keep everything straight. It puts the data from your Documents folder into a similar folder on the server. If you changed the source folder to “~/” then change this to “USER@SERVER:/~/laptop.bak/”

This first time running the sync may take quite a while, depending on how much data you have, and how fast your network connection is. You may want to leave it running overnight. The good news is, once you’ve done this sync one time, it will only have to transfer the data that’s changed. It generally takes less than a minute for me to run the backup, unless I’ve altered a ton of data.

It’s perfectly fine to leave this project right where it is, and pick up the second half later. In fact, I’m going to save it for a second post. Rest content in the knowledge that your critical data has been backed up to a remote server. Next post, I’ll show to automate the backup, so that you can forget all about it. While you’re waiting, why not take a minute to digg this post.

(continue reading part 2)

70 thoughts on “How To: Backup your Mac to a Dreamhost Server (part 1 of 2)

  1. Sweet… in the words of Borat “Isz Niiiiice”

    So from now on all i have to do is just run rsync with the avz switch and it’ll copy only new files over ?

  2. Michael,

    When y do “ssh USER@SERVER”, the server pront me for the password.

    Same thing when I do “rsync -avz ~/Documents/ USER@SERVER:~/laptop.bak/Documents/”

    the applescript gives the following error, because it has not a password:

    ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory
    Permission denied, please try again.
    ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory
    Permission denied, please try again.
    ssh_askpass: exec(/usr/libexec/ssh-askpass): No such file or directory
    Permission denied (publickey,password).
    rsync: connection unexpectedly closed (0 bytes received so far) [sender]
    rsync error: unexplained error (code 255) at /SourceCache/rsync/rsync-35.2/rsync/io.c(452) [sender=2.6.9]

    Can you give me a hint. Thanks

  3. For anyone reading this now, Dreamhost have added the option to set up a backup user specifically for this kind of backup. You basically get an additional 50G on a different server to your webspace to do personal backups – only stipulation is nothing illegal.

    Sounds fair to me.

    I’ve just gone through this tutorial and everything worked fine. Thanks.

Leave a Reply