The snapshots have names like hourly, daily,
weekly and a date_time (and optional expiration) prefix.
The snapshots are stored in a .snapshot/ directory in the
subvolume root. Example:
/local/home/.snapshot/2017-09-09_1200.hourly
You create a snapshot with:
snaprotate CLASS COUNT SUBVOL
If count is exceeded then the oldest snapshot will be deleted → snapshot rotation
Alternativly you can create a snapshot with:
snaprotate CLASS KEEP[dhm] SUBVOL
Example usage:
root@fex:~# snaprotate -s
snapshootable directories:
/backup
/local
/local/home
root@fex:~# snaprotate single 3 /local/home
Create a readonly snapshot of '/local/home' in '/local/home/.snapshot/2017-09-09_1322.single'
root@fex:~# snaprotate -l
/backup/.snapshot/2017-09-08_0831.single
/local/home/.snapshot/2017-09-09_0000.daily
/local/home/.snapshot/2017-09-09_1200.hourly
/local/home/.snapshot/2017-09-09_1300.hourly
/local/home/.snapshot/2017-09-09_1322.single
Example entries for your crontab:
0 * * * * snaprotate -q hourly 2 /local/home
0 0 * * * snaprotate -q daily 3 /local/home
0 0 * * 1 snaprotate -q weekly 1 /local/home
Full usage:
usage: snaprotate [-v] [-q] CLASS COUNT SUBVOL(s)
usage: snaprotate [-v] [-q] CLASS KEEP[dhm] SUBVOL(s)
usage: snaprotate -s
usage: snaprotate -l [FILE]
usage: snaprotate -S 'FILEPATTERN'
usage: snaprotate -R [FILE]
usage: snaprotate -d [SUBVOL]
help: snaprotate -H
options:
-v verbose mode
-q quiet mode
-s show snapshootable subvolumes
-l list snapshots (containing FILE)
-S search snapshooted file(s)
-R recover file or directory
-d query and delete snapshot
examples:
snaprotate daily 7 /home # create and rotate 7 "daily" snapshot
snaprotate boot 3d / # create "boot" snapshot, keep it 3 days
snaprotate test 0 /tmp # delete all "test" snapshots
snaprotate -l /home # list snapshots
snaprotate -R # recover file (guided)
zsnaprotate creates and manages ZFS readonly snapshots similar to Netapp.
zsnaprotate works like snaprotate for btrfs but the snapshots are stored
in the $ZFSROOT/.zfs/snapshot/ directory. Example:
/data/.zfs/snapshot/2017-09-09_1200.hourly
Author: Ulli Horlacher