Compute Questions
Software Questions
Data Questions
How Do I Recover ZFS Files?
Files on ZFS are backed up in “snapshots” for some amount of time, so if you need to recover something you accidentally deleted, luckily you can still access it! Inside of each ZFS project or home directory is a hidden directory called .zfs/snapshot/
. If you navigate into that hidden directory, you will see all available snapshots and can recover files from them.
Here is an example of something that might happen:
- You are working in the directory
/zfs/projects/faculty/hello-world/
and have a couple of files namedresults.csv
andresults_temp.csv
that you made yesterday. The latter file was clearly temporary and so you want to remove it to clean things up:rm /zfs/projects/faculty/hello-world/results.csv
- Oops, you accidentally deleted the file you wanted to keep! Only
results_temp.csv
remains. Luckily, since you made the files yesterday, there are likely snapshots available in/zfs/projects/faculty/hello-world/.zfs/snapshot/
. Browsing that directory, you’ll see 10-minute, Hourly, Daily, Weekly, and Monthly snapshots. You can simply copy over the file you deleted from yesterday:cp /zfs/projects/faculty/hello-world/.zfs/snapshot/zrepl_20211118_223651_000/results.csv /zfs/projects/faculty/hello-world/
Note that snapshots are taken every 10 minutes and retained at very set frequencies. The current snapshot retainment policy is as follows:
- 10-minute — retain most recent hour’s worth of snapshots
- Hourly — retain 1 day of hourly snapshots
- Daily — retain 1 week of daily snapshots
- Weekly — retain 1 month of weekly snapshots
- Monthly — retain 1 year of monthly snapshots
Connect with us