KB450260 – Enabling Automated ZFS Snapshots in CentOS

Last modified: December 11, 2020
You are here:
  • KB Home
  • KB450260 – Enabling Automated ZFS Snapshots in CentOS
Estimated reading time: 1 min

KB450260 – Enabling Automated ZFS Snapshots in CentOS

Scope/Description:

The article will walk through how to enable automated ZFS snapshots in CentOS

Prerequisites:

Steps:

  • Snapshots are enabled at the pool or dataset level.
  • The ZFS command is used to enable snapshots.
  • Snapshots are rotated at the set default value listed below.
    • To change amount of snapshots kept, edit the –keep flag in the corresponding cron file.
    • For example to keep only 8 hourly snaphots, change the keep vluae to 8 from 24 in “/etc/cron.hourly/zfs-auto-snapshot

Any combination of the below can be used at the same time.

  • To enable Frequent (Every 15 Minutes) snapshots on a zpool named tank. By default 4 snapshots are kept.
[root@centos~]# zfs set com.sun:auto-snapshot=true tank
  • To enable Hourly snapshots on a zpool named tank. By default 24 snapshots are kept
[root@centos~]# zfs set com.sun:auto-snapshot:hourly=true tank
  • To enable Daily snapshots on a zpool named tank. By default 31 snapshots are kept
[root@centos~]# zfs set com.sun:auto-snapshot:daily=true tank
  • To enable Weekly snapshots on a zpool named tank. By default 8 snapshots are kept
[root@centos~]# zfs set com.sun:auto-snapshot:weekly=true tank
  • To enable Monthly snapshots on a zpool named tank. By default 12 snapshots are kept.
[root@centos~]# zfs set com.sun:auto-snapshot:monthly=true tank

Verification:

  • You can force a snapshot to verify it with:
[root@centos~]# /etc/cron.daily/zfs-auto-snapshot

Optional:

  • You can make the snapshots visible by entering the following command

[root@centos~]# zfs set snapdir=visible “TANK NAME”

E.g. [root@centos~]# zfs set snapdir=visible tank

Verify by going into tank and doing ls -al and .zfs should be visible

Troubleshooting:

Was this article helpful?
Dislike 0
Views: 25
Unboxing Racking Storage Drives Cable Setup Power UPS Sizing Remote Access