Snapshot directory

updated 1 May 2025

Sometimes you're working on something and in a moment of inattention, you delete or overwrite some important file that you've been working on a long time and don't have a good backup or version-controlled copy of. All is not lost! Our fileserver keeps regular "snapshots" of all files in your home directory as a way to defend against this scenario.

Typical interaction

Suppose you've been editing a few files in your directory. You've got two different cpp files, hello.cpp and other.cpp, as shown here:

ls: a.out hello.cpp other.cpp

After a bit of work, you decide you're done with other.cpp and ready to delete it. But in a moment of inattention, you delete the wrong one!

rm hello.cpp

Oh no! But here is where you can check the snapshots. If you look in the directory /home/.snapshot you will find a number of directories labelled according to when the "snapshot" was taken:

daily, hourly, weekly

In general, you'll be able to find hourly snapshots from the top of the hour for the last day or so; daily snapshots from just after midnight for the last week; and weekly snapshots from early Tuesday morning for the last month. The exact timestamp of each is noted in the filename (which gives the date in the format "2025-05-01" and the time after the underscore in 24-hour clock time, always four digits). For many cases you'll want the most recent hourly snapshot, but if you don't notice a mistake immediately you can select the date/time that works best.

Once you've chosen a snapshot to look at, inside that directory you'll look for your own username and, inside that, whatever sub-directory within your own home directory you'd like.

ls snapshot

You could cd into the snapshot directory if you like, and can use the usual commands like cat and vim to inspect them and interact with them, although you cannot write to the snapshot files (all are automatically read-only). Once you've identified what you want to recover, you'll probably use cp to copy it back into your regular home directory (wherever it was lost from, probably).

cp /home/.snapshot/hourly.2025-05-01_2305/dblaheta/hello/hello.cpp .

From that point it's just like any other file and you can edit and change it as necessary.