ZFS – Creating snapshots

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.

464 Replies to “ZFS – Creating snapshots”

  1. Hey there. I discovered your site by means of Google whilst searching for a comparable matter, your site came up. It looks good. I have bookmarked it in my google bookmarks to come back then.

  2. Hiya, I’m really glad I have found this info. Today bloggers publish just about gossip and internet stuff and this is actually irritating. A good site with interesting content, that’s what I need. Thank you for making this web-site, and I’ll be visiting again. Do you do newsletters by email?

  3. Hello there. I found your web site by the use of Google even as looking for a similar matter, your website got here up. It looks great. I have bookmarked it in my google bookmarks to visit then.

  4. Hiya, I’m really glad I have found this information. Nowadays bloggers publish only about gossip and net stuff and this is actually frustrating. A good site with exciting content, that is what I need. Thanks for making this website, and I will be visiting again. Do you do newsletters by email?

  5. Awesome write-up. I am a regular visitor of your blog and appreciate you taking the time to maintain the nice site. I’ll be a regular visitor for a long time.

  6. Hello there. I found your blog via Google whilst looking for a similar matter, your website came up. It seems to be great. I have bookmarked it in my google bookmarks to visit then.

  7. Hiya, I’m really glad I have found this info. Nowadays bloggers publish only about gossip and web stuff and this is actually irritating. A good website with exciting content, that’s what I need. Thank you for making this site, and I will be visiting again. Do you do newsletters by email?

  8. Hey there. I discovered your site by the use of Google at the same time as searching for a comparable matter, your web site came up. It appears good. I have bookmarked it in my google bookmarks to come back then.

  9. Hiya, I am really glad I’ve found this info. Today bloggers publish just about gossip and web stuff and this is really frustrating. A good site with exciting content, this is what I need. Thanks for making this web site, and I will be visiting again. Do you do newsletters by email?

  10. Hiya, I’m really glad I have found this info. Today bloggers publish just about gossip and net stuff and this is really frustrating. A good website with interesting content, that is what I need. Thanks for making this web-site, and I will be visiting again. Do you do newsletters by email?

  11. Hiya, I am really glad I’ve found this info. Nowadays bloggers publish just about gossip and net stuff and this is really annoying. A good website with interesting content, this is what I need. Thank you for making this web site, and I’ll be visiting again. Do you do newsletters by email?

  12. Hello there. I discovered your web site by way of Google even as searching for a similar subject, your website came up. It seems good. I’ve bookmarked it in my google bookmarks to come back then.

  13. Awesome write-up. I’m a regular visitor of your website and appreciate you taking the time to maintain the excellent site. I’ll be a regular visitor for a long time.