Skip to content

zfs snapshot and pruning

Rod Myers edited this page Feb 28, 2020 · 8 revisions

PLEASE NOTE: I am using trident as the zpool name, adjust as you need to

for those wishing to take automatic snapshots of the ~/HOME directory.

first install zfs-prune-shapshots. either using octoxbps or command line

This will clean out ONLY the ~/HOME snapshots.

open a terminal and type the following;

mkdir bin touch bin/snapshot.sh chmod 744 bin/snapshot.sh lte bin/snapshot.sh

now copy and paste the following into the file;

#!/bin/sh

working - all of /home

/bin/zfs snapshot -r trident/home@date +"%F"-"%H":"%M"

working - /home/$USER

/bin/zfs snapshot -r trident/home/john@date +"%F"-"%H":"%M"

note there are two options. 1 for all of ~/HOME, the other for your users ~/HOME only. Save the file and close

now type;

sudo lte /var/spool/cron/root

copy and paste the following;

0 0,2,4,6,8,10,12,14,16,18,20,22 * * * /usr/home/john/bin/snapshot.sh 0 3 * * * /bin/zfs-prune-snapshots -v 1w trident/home >> /var/log/snapshot.log

the top line takes a snapshot of your ~/HOME every two hours. And the bottom line will delete the snapshot(s) after a week.

Save and close the text editor.

this should start snapshotting your system every 2 hours