Snapshots

What are snapshots?

Your ECE disk space takes automatic "snapshots" or backups of the files in your home directory every several hours during the day. These rolling backups are available up to one week in the past, meaning you have the ability to recover a file from your home directory as it existed up to a week ago. This is useful for times when you accidentally delete or overwrite a file.

The snapshots can be accessed using a special, hidden directory named .snapshot that exists for every directory in your home directory but doesn't display using any directory listing command or file browsing application.

In the .snapshot directories, you will find several directories named with a time interval and a number. For example, in the listing of contents for the .snapshot directory below:

% ls .snapshot 
hourly.0 hourly.3 hourly.6 nightly.1 nightly.4 
hourly.1 hourly.4 hourly.7 nightly.2 nightly.5 
hourly.2 hourly.5 nightly.0 nightly.3 weekly.0 

...we have 8 hourly snapshots, 6 daily snapshots, and 1 weekly snapshot.

When are the snapshots are taken?

  • Hourly snapshots are taken every four hours, at 4am, 8am, noon, 4pm, and 8pm.
  • Daily snapshots are taken every Monday through Saturday at midnight.
  • Weekly snapshots are taken every Sunday at midnight.

The higher the number in the name of the snapshot directory, the older that snapshot is. For example, hourly.0 is the latest "hourly" snapshot taken on the most recent four-hour time interval.

Tip: If you are in a UNIX shell, you can use the ls -lu command to print out a "long" directory listing of a .snapshot directory along with dates of when the snapshot were created.

How do I recover a file from a snapshot?

If you take a look inside one of the snapshot directories, you will notice that it is an exact copy of your files as they existed at the time the snapshot was taken. To recover a file found in a snapshot, simply copy it to where you want it. Let's take a look at some examples of recovering a file.

Example

I had a directory named "demo" in my home directory with a file in it named main.c. The file main.c existed since yesterday before midnight, but I just now deleted it, at 10am. The latest hourly snapshot was taken at 8am, and since the file existed at that time, I will check there first:

 % ls .snapshot/hourly.0/demo/ 

Found it! Now let me copy it back to where it was:

% cp .snapshot/hourly.0/demo/main.c ~/demo 

I have now successfully restored the main.c file I accidentally deleted.

Note: If I had modified the file between when the lastest snapshot was taken (8am) and now (10am), I would have only been able to recover the file as it existed at 8am and would have lost my work between 8am and 10am.

I don't see my file in any of the snapshots, what's wrong?

Unfortunately, if you don't see the file in any of the snapshot directories, then it is impossible to recover. It means one of two things:

  • You deleted the file one week ago or more and it's no longer available in even the oldest snapshot.
  • The file didn't exist in your home directory when a snapshot was taken (see the snapshot schedule above). This can happen if you create and delete your file between any scheduled snapshots. For example if you created a file at 9am and deleted it at 11am, it would not have been captured by either the 8am or noon snapshots and would be unrecoverable.