Using Snapshots from Unix
Locating Files in the Snapshots
Each directory in the NetApp filesystem contains an invisible directory called .snapshot, which usually does not appear in directory listings. (The .snapshot directory is only visible at the mount point of the NetApp filesystem.) You must explicitly refer to .snapshot in order to use it. Beneath the .snapshot directory are some more directories, each of which corresponds to a snapshot. The hourly snapshots are named hourly.N where N is a number. Nightly snapshots are named nightly.N. Each of these .snapshot/* directories is a complete copy of the live directory, frozen at the moment the snapshot was created. Suppose you inadvertently delete a file called foo in your home directory. You might find snapshotted versions of it named .snapshot/hourly.0/foo or .snapshot/nightly.1/foo, etc. Note that snapshots are not taken continuously. They are discrete events that happen on a regular schedule. If you create a new file and delete it before any snapshot is taken, it is irretrievably lost.Since every directory in the live filesystem has an invisible .snapshot directory, you can access a file in a snapshot with different paths. Suppose you lost the file foo/bar and that the backup copy that you want is in snapshot hourly.1. You can retrieve the file a couple of different ways. You can get it from .snapshot/hourly.1/foo/bar or you can get it from foo/.snapshot/hourly.1/bar. This is a very handy feature. Suppose you delete the entire foo directory and later discover that you need foo/bar back. You would be unable to use foo/.snapshot because foo no longer exists in the live filesystem. Fortunately, foo still exists in the snapshot as .snapshot/hourly.1/foo so you can retrieve file bar from there.
Each .snapshot directory and everything beneath it is strictly read-only. You cannot create, remove, or modify anything.
Cookbook Example
If you can use the Unix commands ls and cp, you can restore your own files from snapshots. Assume you have lost the file foo in the current directory. Figure out which snapshotted version of foo that you want back with this command.ls -lt .snapshot/*/fooThis lists information about the snapshotted copies of foo, sorted by modification time. The output will look something like this:
-rw-r--r-- 1 twh staff 5347 Aug 12 11:32 .snapshot/hourly.0/foo -rw-r--r-- 1 twh staff 5347 Aug 12 11:32 .snapshot/hourly.1/foo -rw-r--r-- 1 twh staff 5213 Aug 12 10:01 .snapshot/hourly.2/foo -rw-r--r-- 1 twh staff 5213 Aug 12 10:01 .snapshot/nightly.1/foo -rw-r--r-- 1 twh staff 4774 Aug 11 13:07 .snapshot/nightly.0/foo
The number to the left of the date is the size of the file in bytes. This might also help you decide which version of the file you want back. And of course, you can always look at these files with pg, more, cat or your favorite editor. Suppose you have decided to restore .snapshot/hourly.1/foo. Simply copy it with cp
cp .snapshot/hourly.1/foo fooNote that if file foo exists and you are copying over it, the cp command may fail with the error
cp: .snapshot/hourly.1/foo and foo are identical (not copied)The two files are not identical, but cp has been fooled by the snapshot. You should remove foo with rm foo or rename it with mv foo foo.bad and then the cp command will work.
If the command ls -lt .snapshot/*/foo fails with an error message such as .snapshot/*/foo: No such file or directory, then there is no file named foo (from this directory) in any snapshot. Perhaps you had the file in a different directory. Repeat the above procedure from the correct directory. Perhaps you lost the file before the NetApp made any snapshot of it, in which case you are out of luck. Or perhaps you lost the file long enough ago that all the snapshots that contained it have been deleted. You will have to run "restore_request".
| Page Owner: Phirum Peang | Last Modified: Thu Sep 2 09:17:43 2004 |