45 Drives Knowledge Base
KB450260 - Enabling Automated ZFS Snapshots in CentOS
https://knowledgebase.45drives.com/kb/kb450260-enabling-automated-zfs-snapshots-in-centos8/

KB450260 - Enabling Automated ZFS Snapshots in CentOS

Posted on November 30, 2020 by Brett Kelly


KB450260 - Enabling Automated ZFS Snapshots in CentOS

Scope/Description:

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

Prerequisites:

Steps:

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

# zfs set com.sun:auto-snapshot=true tank
# zfs set com.sun:auto-snapshot:hourly=true tank
# zfs set com.sun:auto-snapshot:daily=true tank
# zfs set com.sun:auto-snapshot:weekly=true tank
# zfs set com.sun:auto-snapshot:monthly=true tank

Verification:

# /etc/cron.daily/zfs-auto-snapshot

Optional:

# zfs set snapdir=visible "TANK NAME"

E.g. # zfs set snapdir=visible tank

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

Troubleshooting:

KB450260 – Enabling Automated ZFS Snapshots in CentOS – 45 Drives Knowledge Base

KB450260 – Enabling Automated ZFS Snapshots in CentOS

Last modified: May 24, 2021
You are here:
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: 43
Unboxing Racking Storage Drives Cable Setup Power UPS Sizing Remote Access