Recovering Files from a Snapshot Using UNIX Command Line

Any user who stores files on the EGR network space (home space, web space, and research space) is able to access snapshots to recover previous file versions (files which may have been accidentally changed or deleted) without assistance from DECS. The following procedure is for users using the UNIX command line interface (i.e. - ssh connection to scully).
 
A snapshot is a read-only copy of the entire file system and all the files contained in the file system. The contents of each snapshot reflect the state of the file system at the time the snapshot was created. It is easy to navigate through each snapshot as if it were still active. Your directories/folders and files will appear as they were at the time that the snapshot was created. Snapshots are taken on the this schedule.

You can easily recover your own files, as far back as four weeks ago, simply by copying an earlier version from the snapshot to the original directory. If you need a file restored from tape please fill out this form to submit your request for DECS to restore your file(s) from backup tapes.

Snapshot Recovery Procedure

The following example shows how to recover a file located in a specific folder.

  1. Move to the directory where you want the file that you will be recovering to be once the file is recovered. Within this and all directories is a hidden directory called ".snapshot".

    Note: This directory does not appear with "ls" using any options, but is accessible with "cd".

    <71 scully:~ >cd .snapshot
    <72 scully:~/.snapshot >pwd
    /home/username/.snapshot

    Note: If you are unsure of the location of the file(s) you are attempting to recover, keep in mind that you can first change into the .snapshot directory then move into the .snapshot directory/folder where the file you want to recover is stored.

  2. Type ls
    you will see the hourly, nightly and weekly snapshot archives.

    To see the timestamps associated with the creation of each of the snapshots, type ls -lu.
    The timestamps will help you select the appropriate snapshot to use to recover your file(s).

    Note: These timestamps are an approximation. If there have not been any modification to file(s) in your directory a new snapshot is not created.

  3. Next, change to the snapshot directory that you believe contains the version of the file(s) you want to recover. For example, "cd hourly.2". The most recent backup copy has the lowest value (i.e., hourly.0 is the most recent, and hourly.22 is the oldest).

    If you type "pwd", you will see that you are two directory levels below the directory in the active file system.

    <73 scully:~/.snapshot/hourly.2 >pwd
    /home/username/.snapshot/hourly.2
    <74 scully:~/.snapshot/hourly.2 >ls -a
    ... file1 file2 file3

  4. To overwrite your current file with the file that you are recovering, simply copy it to its original location. For a copy of the file, use the cp command as follows:

    <75 scully:~/.snapshot/hourly.2 >cp file2 ~/.

    To save the recovered file to a different file name, to distinguish it from the current active file, use as follows:

    <75 scully:~/.snapshot/hourly.2 >cp file2 ~/file2.R

  5. Return to the active file system. You should see that your file is now available:

    <76 scully:~/.snapshot/hourly.2 >cd ~
    <77 scully:~ >pwd
    /home/username
    <78 scully:~/path >ls -a
    ... file1 file2 file3