Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
abstract:zfs-snapshots [2019/03/15 17:00] frey |
abstract:zfs-snapshots [2019/03/15 17:18] (current) frey [Accessing a snapshot] |
||
---|---|---|---|
Line 9: | Line 9: | ||
Each snapshot of a ZFS file system represents a point-in-time copy, making it an online backup copy of the file system. In many instances, the same snapshots are periodically transmitted to a secondary (often off-site) server where they guarantee recoverability of the file system should the primary server suffer a catastrophic failure. | Each snapshot of a ZFS file system represents a point-in-time copy, making it an online backup copy of the file system. In many instances, the same snapshots are periodically transmitted to a secondary (often off-site) server where they guarantee recoverability of the file system should the primary server suffer a catastrophic failure. | ||
- | ===== Accessing snapshots ===== | + | ===== Listing snapshots ===== |
Any user having access to the root mount point of a ZFS file system can see a list of available snapshots. For example, my home directory on the [[caviness:start|Caviness]] community cluster is backed by a ZFS file system. To display all available snapshots: | Any user having access to the root mount point of a ZFS file system can see a list of available snapshots. For example, my home directory on the [[caviness:start|Caviness]] community cluster is backed by a ZFS file system. To display all available snapshots: | ||
Line 28: | Line 28: | ||
20190314-1815 | 20190314-1815 | ||
20190315-0615 | 20190315-0615 | ||
+ | </code> | ||
+ | |||
+ | Each directory displayed is named according to the date and time the snapshot in question was created. Note that the names at the top of the listing have a by-month granularity, increasing to a by-week, by-day, and bi-daily granularity moving down the list. This demonstrates that for my home directory on Caviness: | ||
+ | |||
+ | * snapshots are created twice each day, at 6:15 a.m. and p.m. | ||
+ | * as time goes by, snapshots are removed in such a way that a single weekly and monthly (and eventually, yearly) snapshot remains | ||
+ | |||
+ | This pattern only holds so long as my usage remains well below my quota. If I use more and more capacity, the number of snapshots will decrease. | ||
+ | |||
+ | ===== Accessing a snapshot ===== | ||
+ | |||
+ | Each snapshot under ''.zfs/snapshot'' is itself a directory, which can be navigated from the filesystem using the standard Linux file system commands (like ''cd'' and ''ls''). The files and directories present in the snapshot cannot be modified (''rm'' and ''mv'' will not work, neither will attempts to edit files in place), but they can be read (e.g. with ''less'' or ''head'') | ||
+ | <code bash> | ||
+ | [frey@login00 ~]$ ls -l ~/trace.txt | ||
+ | ls: cannot access /home/1001/trace.txt: No such file or directory | ||
+ | [frey@login00 ~]$ ls -l ~/.zfs/snapshot/20190206-0115/trace.txt | ||
+ | -rw-r--r-- 1 frey everyone 336436 Jan 25 09:39 /home/1001/.zfs/snapshot/20190206-0115/trace.txt | ||
+ | [frey@login00 ~]$ head -5 ~/.zfs/snapshot/20190206-0115/trace.txt | ||
+ | # | ||
+ | # This file contains a code trace | ||
+ | # from a run of my program that is | ||
+ | # failing... | ||
+ | # | ||
+ | </code> | ||
+ | or copied to some writable location using ''cp'' | ||
+ | <code bash> | ||
+ | [frey@login00 ~]$ cp -a ~/.zfs/snapshot/20190206-0115/trace.txt ~/trace.txt | ||
+ | [frey@login00 ~]$ ls -l ~/trace.txt | ||
+ | -rw-r--r-- 1 frey everyone 336436 Jan 25 09:39 /home/1001/trace.txt | ||
+ | [frey@login00 ~]$ head -5 ~/trace.txt | ||
+ | # | ||
+ | # This file contains a code trace | ||
+ | # from a run of my program that is | ||
+ | # failing... | ||
+ | # | ||
</code> | </code> |