Snapshots

For filesystems located on the CSL Network Appliance Filer, users can recover multiple versions of files - that have been deleted or corrupted - without lab staff help by using the snapshot facilty. The following is taken from the Network Appliance online support document.

Every directory in the file system contains a hidden sub-directory named .snapshot which contains multiple copies of that directory, as it existed at the time the snapshot was taken. Browsing these directories allows the user to recover a version of a file from any time for which a snapshot exists. As an example, suppose that a user has accidentally removed a file named todo and wants to recover it. The following example shows how to list all the versions of todo saved in Snapshots:

spike% ls -lut .snapshot/*/todo

-rw-r--r-- 1 hitz 52880 Oct 15 00:00 .snapshot/nightly.0/todo

-rw-r--r-- 1 hitz 52880 Oct 14 19:00 .snapshot/hourly.0/todo

-rw-r--r-- 1 hitz 52829 Oct 14 15:00 .snapshot/hourly.1/todo

-rw-r--r-- 1 hitz 55059 Oct 10 00:00 .snapshot/nightly.4/todo

-rw-r--r-- 1 hitz 55059 Oct 9 00:00 .snapshot/nightly.5/todo

By using the -u option, ls shows the file's access time, which corresponds to the time when the Snapshot containing it was created. The user can recover the most recent version of todo by copying it back into the current directory:

spike% cp .snapshot/hourly.0/todo .

The .snapshot directories are hidden in the sense that they do not show up in directory listings, and unlike the typical behavior hidden dotfiles familiar to UNIX users, the .snapshot directories do not show up even in the ls -a command. If .snapshot were visible, commands like find would report many more files than expected, and commands like rm -r would fail because files in Snapshots are read-only and cannot be removed.

Other than the restrictions mentioned above, Snapshot directories can be treated as usual, read-only filesystem directories.

CS-specific setup

Not all filesystems in the department are hosted on the NetApp filer, but the home directories and most of the project directories are. You can determine if the filesystem you are using has snapshots by using the df command. If you run the following command, you can see which filesystem and fileserver your current directory is served from.

% df . Filesystem kbytes used avail capacity Mounted on compsci-01:/home 26214400 9205144 17009256 36% /home/users

If the filesystem is located on the host compsci-01, as in the example above, then you will be able to use the snapshot facility.

  • There is a .snapshot directory in every directory for filesystems on the filer; you can't see them, you can't use shell autocompletion on them, you just need to blindly type them (once you are "inside" the Snapshots directory, autocompletion will work).
  • During each day, "hourly" snapshots are taken at 4 hour intervals, at: 0000, 0400, 0800, 1200, 1600, and 2000. These are only available for 24 hours, until they are overwritten.
  • Nightly (0000 or midnight) snapshots are kept for 30 days.
  • Monthly snapshots are retained within space constraints; these currently tend to number between three and six.
  • As a convenience, to access your files as of yesterday, you may use the link yesterday that is in your home directory.

The listing below represents a typical collection of daily, nightly and monthly backups.

% ls -lu /home/users/fred/personal/.snapshot total 40960

drwxr-x--x 111 fred users 1044480 Mar 21 16:00 hourly.0

drwxr-x--x 111 fred users 1044480 Mar 21 12:00 hourly.1

drwxr-x--x 111 fred users 1044480 Mar 21 08:00 hourly.2

drwxr-x--x 111 fred users 1044480 Mar 21 04:00 hourly.3

drwxr-x--x 111 fred users 1044480 Mar 20 20:00 hourly.4

drwxr-x--x 111 fred users 1044480 Mar 20 16:00 hourly.5

drwxr-x--x 111 fred users 1044480 Mar 21 00:00 nightly.0

drwxr-x--x 111 fred users 1044480 Mar 20 00:00 nightly.1

drwxr-x--x 111 fred users 1044480 Mar 11 00:00 nightly.10

drwxr-x--x 111 fred users 1044480 Mar 10 00:00 nightly.11

drwxr-x--x 111 fred users 1044480 Mar 9 00:00 nightly.12

drwxr-x--x 111 fred users 1044480 Mar 8 00:00 nightly.13

drwxr-x--x 111 fred users 1044480 Mar 7 00:00 nightly.14

drwxr-x--x 111 fred users 1044480 Mar 6 00:00 nightly.15

drwxr-x--x 111 fred users 1044480 Mar 5 00:00 nightly.16

drwxr-x--x 111 fred users 1044480 Mar 4 00:00 nightly.17

drwxr-x--x 111 fred users 1044480 Mar 3 00:00 nightly.18

drwxr-x--x 111 fred users 1044480 Mar 2 00:00 nightly.19

drwxr-x--x 111 fred users 1044480 Mar 19 00:00 nightly.2

drwxr-x--x 111 fred users 1044480 Mar 1 00:00 nightly.20

drwxr-x--x 111 fred users 1044480 Feb 28 00:00 nightly.21

drwxr-x--x 111 fred users 1044480 Feb 27 00:00 nightly.22

drwxr-x--x 111 fred users 1044480 Feb 26 00:00 nightly.23

drwxr-x--x 111 fred users 1044480 Feb 25 00:00 nightly.24

drwxr-x--x 111 fred users 1044480 Feb 24 00:00 nightly.25

drwxr-x--x 111 fred users 1044480 Feb 23 00:00 nightly.26

drwxr-x--x 111 fred users 1044480 Feb 22 00:00 nightly.27

drwxr-x--x 111 fred users 1044480 Feb 21 00:00 nightly.28

drwxr-x--x 111 fred users 1044480 Feb 20 00:00 nightly.29

drwxr-x--x 111 fred users 1044480 Mar 18 00:00 nightly.3

drwxr-x--x 111 fred users 1044480 Mar 17 00:00 nightly.4

drwxr-x--x 111 fred users 1044480 Mar 16 00:00 nightly.5

drwxr-x--x 111 fred users 1044480 Mar 15 00:00 nightly.6

drwxr-x--x 111 fred users 1044480 Mar 14 00:00 nightly.7

drwxr-x--x 111 fred users 1044480 Mar 13 00:00 nightly.8

drwxr-x--x 111 fred users 1044480 Mar 12 00:00 nightly.9

drwxr-x--x 109 fred users 1044480 Jan 1 00:00 snap.060101

drwxr-x--x 109 fred users 1044480 Feb 1 00:00 snap.060201

drwxr-x--x 111 fred users 1044480 Mar 1 00:00 snap.060301

Number and frequency of snapshots in the home partitions and project partitions will not always be the same, and they can vary due to system constraints. You can always check with "ls .snapshot". Note that shell filename autocompletion will not work with the name ".snapshot".

If you have additional questions, please contact the the Lab Staff.