Restoring a deleted file

If you accidentally deleted a file, all is not lost. Older copies of your file are available in the .snapshot directory located in the directory where the deleted file previously existed. Daily snapshots are taken at 4:00 AM, 12:00 PM, and 8:00 PM. The directory names will include a timestamp indicating when the directory was created (e.g., daily-snap-8pm-umn-s_2020-03-03_19-55). To recover the last snapshot of the file that was accidentally deleted:

  1. cd to the .snapshot directory in the directory where the file previously existed
  2. list the contents of the directory using the ‘ls’ command
  3. The output of the ‘ls’ command will show that there are directories for each of the three daily snapshots for the past 30 days.
  4. From the available snapshots, choose the directory immediately prior to the time you deleted the file. For example, if you deleted the file at 11:00 on 1/1/2020, chose the snapshot directory for 4 AM as that would contain the last copy of the file. If you’re not sure when the file went missing, look in the directory with the most recent timestamp to see if it has the file you want to restore. If not, continue on and look in the directory with the second most recent timestamp. If it was deleted a while ago, you may need to search back through a few directories to find the last copy of the file before it was deleted.Once you have found the file, you can copy it to the location where you would like it restored. 

 

Here is an example of how to restore the file test_script.pbs that was accidentally deleted at 9:00 AM on 2/22 from the myproject directory:

goldy@compute:~$ cd myproject
goldy@compute:~/myproject$ ls
stata_test.pbs
goldy@compute:~/myproject$ cd .snapshot
goldy@compute:~/myproject/.snapshot$ ls
daily-snap-12pm-umn-s_2020-02-05_11-55 daily-snap-4am-umn-s_2020-02-22_03-55
daily-snap-12pm-umn-s_2020-02-06_11-55 daily-snap-4am-umn-s_2020-02-23_03-55
daily-snap-12pm-umn-s_2020-02-07_11-55 daily-snap-4am-umn-s_2020-02-24_03-55
daily-snap-12pm-umn-s_2020-02-08_11-55 daily-snap-4am-umn-s_2020-02-25_03-55
...

goldy@compute:~/myproject/.snapshot$ cd daily-snap-4am-umn-s_2020-02-22_03-55
goldy@compute:~/myproject/.snapshot/daily-snap-4am-umn-s_2020-02-22_03-55$ ls
test_script.pbs
stata_test.pbs
goldy@compute:~/myproject/.snapshot/daily-snap-4am-umn-s_2020-02-22_03-55$ cp test_script.pbs ~/myproject
goldy@compute:~/myproject/.snapshot/daily-snap-4am-umn-s_2020-02-22_03-55$ cd ~/myproject
goldy@compute:~/myproject$ ls
test_script.pbs
stata_test.pbs