There is some funky ways of modifying the default “time slider” services to do the work for you, but i like a bit more hands on. Generally so i know what is happening in the background, but the time slider can be sometimes overkill creating snapshots every 15 mins if not configured properly.
On a side note i’ve yet to get my head around the SMF stuff properly… Anyhow onto creating snapshots.
I”ve decided to snapshot both my unprotected and protected zpools.
I’ve created three scripts,this is what my snapdaily.sh script looks like ;
zfs destroy -r protected@daily
zfs destroy -r unprotected@daily
zfs snapshot -r protected@daily
zfs snapshot -r unprotected@daily
echo “Daily ZFS snapshot done” – output saved as part of the crontab job
The other two are similar, but weekly and monthly. The name of the snapshot is after the @ symbol as above. the -r switch is recursive, so all zfs file systems beneath the named zfs also have snapshots created.
next I’ve saved this script and added it to crontab (as root since its zfs commands which are usually restricted);
su – enter password, you are now root.
crontab -e – edit roots crontab file (use vi to insert the following line)
0 5 * * * /protected/snapdaily.sh – this will run every day at 5am.
Run the script first to see if it works, then check with this command;
zfs list -t snapshot – you should see the above snapshots.
Repeat for weekly / monthly as above…
I have disabled all the automatic snapshots….
svcs -a | grep “snapshot” – should show you all the zfs snapshot services
svcadm disable svc:/system/filesystem/zfs/auto-snapshot:daily – etc, will disable these snapshots.
You can also turn off time slider via the GUI if you have turned it on.