tools

various tools I have been using throughout the years
Log | Files | Refs | README | LICENSE

reflink-snap.1.scd (3845B)


      1 reflink-snap(1)
      2 
      3 # NAME
      4 
      5 reflink-snap - reflink (copy-on-write) snapshot manager for XFS
      6 
      7 # SYNOPSIS
      8 
      9 *reflink-snap create* *-s* _SRC_ *-d* _SNAPDIR_ [*-c* _KEEP_] [*-p* _PREFIX_] [*-n*]++
     10 *reflink-snap list* *-d* _SNAPDIR_ [*-p* _PREFIX_]++
     11 *reflink-snap prune* *-d* _SNAPDIR_ *-c* _KEEP_ [*-p* _PREFIX_] [*-n*]++
     12 *reflink-snap verify* _PATH_++
     13 *reflink-snap dedupe* [*--hashfile* _FILE_] _PATH_...
     14 
     15 # DESCRIPTION
     16 
     17 *reflink-snap* creates snapshots of a directory tree on filesystems with
     18 reflink support (XFS formatted with *mkfs.xfs -m reflink=1*, the default
     19 since xfsprogs 5.1). A snapshot is a plain directory named
     20 _SNAPDIR_/[_PREFIX_]<timestamp> copied with *cp -a --reflink=always -x*, so
     21 unmodified data shares extents with the source and costs almost no disk
     22 space. Data blocks are only duplicated when either copy is modified
     23 (copy-on-write).
     24 
     25 A *latest* symlink in _SNAPDIR_ always points at the newest snapshot.
     26 The source and snapshot directory must be on the same filesystem; entries
     27 on other filesystems are skipped. The copy is staged in a hidden temporary
     28 directory and renamed on success, so an interrupted run never leaves a
     29 directory that looks like a valid snapshot.
     30 
     31 # COMMANDS
     32 
     33 *create*
     34 	Snapshot _SRC_ into _SNAPDIR_, update the *latest* symlink, then
     35 	prune if *-c* is given. If _SNAPDIR_ is inside _SRC_, it is excluded
     36 	from the snapshot.
     37 
     38 *list*
     39 	Show snapshots matching _PREFIX_, oldest first. Without _PREFIX_,
     40 	all snapshots (any name ending in a timestamp) are listed.
     41 
     42 *prune*
     43 	Delete the oldest snapshots so that at most _KEEP_ remain. Only
     44 	directories whose name is _PREFIX_ followed by a timestamp (or,	without _PREFIX_, any name ending in a timestamp) are ever deleted.
     45 
     46 *verify*
     47 	Walk _PATH_ and report how much of its file data lives in shared
     48 	(reflinked) extents, using *filefrag*(8). Useful to confirm
     49 	snapshots are actually copy-on-write.
     50 
     51 *dedupe*
     52 	Run *duperemove*(8) to find duplicate blocks under the given paths
     53 	and convert them into reflinks.
     54 
     55 # OPTIONS
     56 
     57 *-s* _DIR_, *--source* _DIR_
     58 	Tree to snapshot (create).
     59 
     60 *-d* _DIR_, *--snapshot-dir* _DIR_
     61 	Directory in which snapshots are kept.
     62 
     63 *-c* _N_, *--keep* _N_
     64 	Number of snapshots to retain.
     65 
     66 *-p* _PREFIX_, *--prefix* _PREFIX_
     67 	Snapshot name prefix. When omitted, commands match any snapshot
     68 	whose name ends in a timestamp, and *create* names snapshots with
     69 	no prefix. Use distinct prefixes for independent schedules, e.g.
     70 	*hourly\_* and *daily\_*.
     71 
     72 *--hashfile* _FILE_
     73 	Persistent hash cache for *dedupe*, avoiding re-hashing unchanged
     74 	data on later runs.
     75 
     76 *-n*, *--dry-run*
     77 	Print the commands that would run instead of executing them.
     78 
     79 *-h*, *--help*
     80 	Show usage.
     81 
     82 # RESTORING
     83 
     84 A snapshot is an ordinary directory tree; restore by copying back out of it:
     85 
     86 ```
     87 cp -a --reflink=always /home/.snapshots/latest/some/file /home/miro/some/file
     88 ```
     89 
     90 # EXAMPLES
     91 
     92 Hourly and daily snapshots of a home directory via cron:
     93 
     94 ```
     95 0 * * * *  reflink-snap create -s /home/miro -d /home/.snapshots -c 48 -p hourly_
     96 0 3 * * *  reflink-snap create -s /home/miro -d /home/.snapshots -c 14 -p daily_
     97 ```
     98 
     99 Confirm the newest snapshot shares its extents with the source:
    100 
    101 ```
    102 reflink-snap verify /home/.snapshots/latest
    103 ```
    104 
    105 # NOTES
    106 
    107 *du* counts reflinked data once per tree, so snapshots look expensive;
    108 *df* is the truth for what they actually cost.
    109 
    110 Snapshots are not atomic (files are copied one at a time), are writable
    111 directories rather than read-only volumes, and live on the same disk as
    112 the source. They protect against accidental deletion or modification, not
    113 against disk failure; keep separate backups.
    114 
    115 # SEE ALSO
    116 
    117 *cp*(1), *filefrag*(8), *duperemove*(8), *xfs*(5)
    118 
    119 # AUTHOR
    120 
    121 Based on alexadriaanse/reflink-snap and Andy Smith's article on XFS
    122 reflinks and deduplication
    123 (https://strugglers.net/posts/2017/xfs-reflinks-and-deduplication/).