Approximately four times per 24 hour period, the NetApp home directory server will look at files that may have been changed or modified since the last scheduled time. If a file has been changed or modified, a copy of it is created and placed in a special directory called “.snapshot”. These files are not held for very long, and it can often be as short as two days. The benefit is that if you inadvertently delete a file or if you quickly realize that you really need a file that you recently deleted, you can get it back.
While most people’s accounts are hosted on the NetApp, there are a few accounts that exist on other servers in ECE. To find out if your account is hosted on the NetApp and can take advantage of the Snapshot backups, log into any ECE department Unix machine and type “homehost” at the command line prompt. If it returns “plum” as a response, your account is hosted on the NetApp and can take advantage of Snapshot backups.
How can I use the Snapshots to restore my data?
- Connect to an ECE Unix host.
- Use the “cd” command to navigate to the .snapshot directory that contains the backed up files. Note that this is a hidden directory and normally does not show up in a typical directory listing. The period in front of the snapshot name is important.
Example: cd .snapshot
- If you view the contents of the .snapshot directory using ls, you will see several subdirectories:
hourly.0/ hourly.2/ hourly.4/ nightly.0/
hourly.1/ hourly.3/ hourly.5/ nightly.1/
As the .snapshot names imply, Snapshots are taken hourly and nightly. The “hourly.0” snapshot is the most recent snapshot, “hourly.1” is from the snapshot preceding “hourly.0” and so forth. The “nightly.0” snapshot reflects the state of your data as of the previous night.
- Cd to the directory from which you would like to restore your data from.
Example: cd hourly.0
- Use the “ls -la” command to see the contents of the directory. The files are as they were when the .snapshot was made. Example:
-rw------- 1 joebloe eceugrad 954512 Dec 12 09:12 example.txt
-rw------- 1 joebloe eceugrad 758600 Dec 11 08:54 mailJunk
- Use the cp command to copy individual files from the .snapshot directory to the directory at which you would like the files to be placed. You will need to specify the file name and the target directory path.
Example (assuming you are in in a .snapshot directory): cp example.txt ~username/labs/
In the example we are copying example.htm from the .snapshot directory to the “labs” directory inside your home directory. make sure to replace “username” with your ECE login name.
NOTE: You cannot copy a file from the .snapshot directory to the target directory if the a file with the same name exists in the target directory. You will need to first rename or delete the file in the target directory before copying the file over.
- You can also use the cp -r command to copy whole directories recursively from the .snapshot directories to the target directory.
Example (assuming you are in in a .snapshot dir): cp -r labs/ ~username/
Why do I get the error “cp: ‘filename’ and ‘/path/to/filename’ are the same file”?
Copying a file from the .snapshot directory to the target location will fail if there is a file in the target directory that has the same name as the file you are copying over. You will need to first rename or delete the file in the target directory before copying the file over.