Snapshots on DreamHost

Update Jan 2010: DreamHost has discontinued this feature.

I just discovered a cool feature at DreamHost called snapshots. This feature lets you access automatic backups of all of your files without contacting DreamHost tech support. I don't know why DreamHost doesn't advertise this feature more heavily; I bet it would cut down on tech support costs and help them attract customers.

To access the snapshots for files in any directory, type cd .snapshot in that direcory. Alternatively, you can cd .snapshot from any ancestor directory and then cd to the desired directory within the snapshot. Snapshot direcoties are hidden from ls -a, gzip, rm -rf, find, and even tab completion, so they don't get in your way when you're not using them. Inside this directory, you will find directories named hourly.0, hourly.1, daily.0, daily.1, weekly.0, and weekly.1. The hourly snapshots are taken every eight hours, the daily snapshots are taken every two days, and the weekly snapshots are taken every week. The .0 snapshots are newer than the .1 snapshots.

Some things you can do with snapshots:

See the dates of all snapshot versions of a file

ls -lt .snapshot/*/sidebar.php

By default, ls shows the date the file was modified (before the snapshot was taken). If you add -u, you can see the date the snapshot was taken instead.

See differences since a snapshot

diff -u .snapshot/nightly.1/sidebar.php sidebar.php | less

Recover an entire directory, including subdirectories

cp --recursive .snapshot/hourly.0/themes themes-recovered
mv themes themes-die
mv themes-recovered themes
rm -rf themes-die

Snapshots are read-only, so you can't accidentally destroy backups. The permissions displayed when you use ls are the permissions of the original files and do not reflect your ability to modify the backups themselves.

The user interface for DreamHost's snapshots is the same as the user interface described in this paper (HTML version), but I don't know what kind of implementation DreamHost is using. In the system described by the paper, snapshots are implemented using copy-on-write at the block level, so they don't take up much server time and disk space when files change slowly.

I found out about DreamHost's .snapshot feature yesterday by following a link from to a DreamHost knowledge base article titled "Backups". I then searched Google for "cd .snapshot" to find out how common this feature is, get ideas for how to use it, and learn how it might be implemented.

If reading about this feature makes you want to use DreamHost as your web host, see Why I love DreamHost for other information about DreamHost and a discount.

11 Responses to “Snapshots on DreamHost”

  1. Albert Feller Says:

    Hey Jesse,

    how much do they pay you?


  2. Jesse Ruderman Says:

    $97 for each signup. I’ve earned a few thousand dollars so far.

  3. Albert Feller Says:

    i guess this should be enough to pay your webhosting bills for quite a while ;-)

  4. DJC Says:

    It sounds like it’s worth signing up just to refer people…! Can you really get $97 just by getting someone else to sign-up?

  5. Jesse Ruderman Says:

    According to DreamHost’s site, you don’t even have to be a customer to make money referring people to DreamHost. (Getting a DreamHost user ID does not require signing up for a web hosting plan.)

  6. Jeremy Dunck Says:

    DJC, you’d also have to have an audience like Jesse has.

    Any idea how they make files not visible even to ls -a?

  7. Jesse Ruderman Says:

    I am curious about that too. It probably happens at the filesystem level so that it can use copy-on-write and block-sharing, so it could be as simple as making the “what files are in this directory?” API function omit .snapshot.

  8. Scott Johnson Says:

    It could be that they have just hacked their copy of “ls” to not display the .snapshot directories. Actually, there are many different hacks that I could think of that could achieve this same result with little effort.

  9. Jerry Kindall Says:

    You don’t need a hacked ls; I’m pretty sure they must be using some filesystem that supports named forks, or something of that nature. Mac OS X lets you access the resource fork of a file as filename/..namedfork/rsrc, for example. Not that they’re using Mac OS X, I’m sure they’re runinng on Intel, probably Linux of some sort — I think ReiserFS supports this, but I’m not a Linux guy so I’ll shut up now.

  10. andy Says:

    Thanks so much for this tip! I was doing some more digging before my 97 days are up to make these guys are for real. I am having a hard time finding anything wrong with them! hourly snapshots!!!! who else does that for $15 a month???

  11. Asko Says:

    It sounds like NetApp Filer (NAS, NFS/CIFS/HTTP/iSCSI). Filer is *very* nice product for file storage and sharing.