NetApp ONTAP Snapshot Policy and Schedule CLI Setup - 夜莺博客

NetApp ONTAP Snapshot Policy and Schedule CLI Setup

ONTAP snapshot copies are instantaneous, space-efficient point-in-time images, but they only protect your data if creation and retention are automated. That automation is a combination of two pieces: a snapshot policy, which defines when to create snapshots, how many to keep, and how to name them, and the job schedules (up to five per policy) that trigger the snapshots. The default policy already creates six hourly, two daily and two weekly snapshots, but production environments usually need their own cadence. This guide shows how to build custom schedules and snapshot policies from the ONTAP CLI and apply them to volumes.

Understanding ONTAP Snapshot Policies

A snapshot policy specifies when to create snapshots, how many copies to retain for each schedule, and how to name them - for example one snapshot every day at 00:10, keeping the two most recent copies, named daily.timestamp. A policy can contain up to five job schedules, each with its own count, prefix and optional SnapMirror label.

Step 1: Create a Job Schedule

Job schedules are cron-style definitions created with job schedule cron create. Month, day-of-week and hour accept all to run on every value:

cluster1::> job schedule cron create -name mydaily -hour 0 -minute 10
cluster1::> job schedule cron create -name myweekly -dayofweek "Saturday" -hour 3 -minute 0
cluster1::> job schedule cron create -name myweeklymulti -dayofweek "Monday,Wednesday,Sunday" -hour 3,9,12 -minute 0,20,50

Step 2: Create the Snapshot Policy

cluster1::> volume snapshot policy create -vserver svm1 -policy snap_policy_daily     -schedule1 mydaily -count1 5 -prefix1 daily -snapmirror-label1 daily

The example creates a policy named snap_policy_daily that runs the mydaily schedule, keeps five snapshots named daily.timestamp, and tags them with the SnapMirror label daily so a SnapMirror relationship can select exactly these copies for replication. Add up to five schedule/count/prefix groups on one policy:

cluster1::> volume snapshot policy create -vserver svm1 -policy prod_hourly_daily     -schedule1 hourly -count1 6 -prefix1 hourly     -schedule2 daily -count2 7 -prefix2 daily     -enabled true

Step 3: Apply the Policy to a Volume

cluster1::> volume snapshot policy modify -vserver svm1 -volume vol1 -policy snap_policy_daily
cluster1::> volume show -vserver svm1 -volume vol1 -fields snapshot-policy

Verifying Schedules, Policies and Snapshots

cluster1::> job schedule cron show
cluster1::> volume snapshot policy show -vserver svm1
cluster1::> volume snapshot show -vserver svm1 -volume vol1

The snapshot list should grow at the scheduled times with the configured prefixes; the oldest copies are deleted automatically when the retention count is exceeded.

Related articles: NetApp ONTAP SnapMirror configuration, NetApp ONTAP CLI cheat sheet, and ONTAP NFS export policy configuration.

原文链接:https://docs.netapp.com/us-en/ontap/data-protection/create-snapshot-policy-task.html