The University of Arizona

Resources

Snapshots

Introduction

The fileservers titan and zuni have a special facility that allows users to restore files that were accidentally deleted or modified. As part of their filesystem management, the fileservers periodically take 'snapshots' of all their filesystems. Users can recover files from these snapshots without any assistance from the Lab staff. The snapshot feature is not a general undelete facility. The fileserver takes snapshots on a fixed schedule, and files that aren't captured in a snapshot cannot be recovered this way.

The snapshot schedule

Student home directories

There are multiple levels of snapshots. The current schedule is as follows: Daily snapshots are taken each morning at midnight. The snapshots taken on Monday mornings are retained for three weeks. The daily snapshots taken on the other days (Tuesday through Sunday) are retained for one week. Snapshots are also taken each day at four hour intervals -- at 4 am, 8 am, 12 noon, 4 pm, and 8 pm. These four-hour-interval snapshots are retained for the past day.

Snapshots are named hourly.[0-5], nightly.[0-5], and weekly.[0-2].

At present, the snapshot scheme involves 15 copies covering a period of roughly three weeks.

Faculty home, cvs, and project directories

There are multiple levels of snapshots. The current schedule is as follows. Daily snapshots are taken each morning at midnight. The snapshots taken on Sunday mornings are retained for five weeks. The daily snapshots taken on the other days (Monday through Saturday) are retained for one week. Snapshots are also taken each day at four hour intervals -- at 4 am, 8 am, 12 noon, 4 pm, and 8 pm. These four-hour-interval snapshots are retained for two days.

Each snapshot is named based on the date and time that it was created in the form of 'MM-DD-hh:mm' (e.g., 02-25-17:13 would represent a snapshot created on February 25th at 17:13 hours).

At present, the snapshot scheme involves 21 copies covering a period of roughly five weeks.

Recovering files from snapshots

Student home directories

The fileserver automatically creates a .snapshot subdirectory for every filesystem.

For each /home/username directory, there is a link .snapshot for that username.

To access these snapshots from lectura:

  $ cd ~/.snapshot

  $ ls
    hourly.0  hourly.3  nightly.0  nightly.3  weekly.0
    hourly.1  hourly.4  nightly.1  nightly.4  weekly.1
    hourly.2  hourly.5  nightly.2  nightly.5  weekly.2

To access the most recent snapshot (per this example):

  $ cd ~/.snapshot/hourly.0

To verify the date that snapshot was created

  $ stat ~/.snapshot/hourly.0|grep Access|tail -1

Faculty home, cvs, and project directories

The fileserver automatically creates a .zfs/snapshot subdirectory for every filesystem.

For each /home/username directory, there is a link .snapshot that points to the .zfs/snapshot subdirectory for that username.

To access these snapshots from lectura:

  $ cd ~/.snapshot

  $ ls
  04-01-00:10 04-25-00:10 04-29-00:10 04-30-04:10 04-30-20:10 05-01-12:10
  04-08-00:10 04-26-00:10 04-29-16:10 04-30-08:10 05-01-00:10
  04-15-00:10 04-27-00:10 04-29-20:10 04-30-12:10 05-01-04:10
  04-22-00:10 04-28-00:10 04-30-00:10 04-30-16:10 05-01-08:10

Note these are directories with names that correspond to the date and time the snapshot was created.

To access the most recent snapshot (per this example):

  $ cd 05-01-12:10/username

Similarly, there is a link .snapshot for each 'top-level' directory under /cs/contrib and /cs/projects.

Example:
  $ cd /cs/projects/solar/.snapshot (or cd /cs/solar/.snapshot)
  $ ls

  04-01-00:10 04-25-00:10 04-29-00:10 04-30-04:10 04-30-20:10 05-01-12:10
  04-08-00:10 04-26-00:10 04-29-16:10 04-30-08:10 05-01-00:10
  04-15-00:10 04-27-00:10 04-29-20:10 04-30-12:10 05-01-04:10
  04-22-00:10 04-28-00:10 04-30-00:10 04-30-16:10 05-01-08:10

  $ cd 05-01-12:10/solar

Recovery (Student or Faculty)

To find a particular file in a snapshot, you would then use standard Unix commands to navigate through a snapshot directory (the file structure is the same as your /home directory). Once you have located the version of the file you are interested in, you can copy it to another location (e.g., your home directory) which will, in effect, restore it.

Note that snapshots are read-only. You cannot edit files within the snapshot area -- you must copy them elsewhere and then edit from that location. Also, you cannot delete directories or files within the snapshot area.

Be aware of file permissions -- especially on sensitive files. If you set a file to be world-readable and it is captured in a snapshot, you won't be able to remove the world-read permission on the snapshot file.

How do snapshots work?

Basically, snapshots are made by cloning the root inode of the filesystem, without copying any disk blocks. Then a copy-on-write technique is used to populate the snapshot as files are modified or deleted.


Last updated October 19, 2016, by Eneida Lima
Send questions about this page to