How to Have Yearly Vaults without a Yearly Snapshot on the Source in ONTAP 9

Image: ONTAP 9
The Theory

In ONTAP 9 there are two additional switches in the snapmirror policy add-rule command:


CL9::> snapmirror policy add-rule
Usage:
  -vserver      Vserver Name
[-policy] SnapMirror Policy Name
[-snapmirror-label]     Snapshot Copy Label
[-keep]                 Snapshot Copy Retention Count
[[-preserve] {true|false}]    Snapshot Copy Preserve Enabled
[ -warn ]           Warning Threshold Count
[ -schedule ]          Snapshot Copy Creation Schedule
[ -prefix ]            Snapshot Copy Creation Prefix


And from the man page:


[-schedule ] - Snapshot Copy Creation Schedule
This optional parameter specifies the name of the schedule associated with a rule. This parameter is allowed only for rules associated with SnapMirror policies of type vault or mirror-vault. When this parameter is specified, Snapshot copies are directly created on the SnapMirror destination. The Snapshot copies created will have the same content as the latest Snapshot copy already present on the SnapMirror destination. Snapshot copies on the source that have a SnapMirror label matching this rule will not be selected for transfer. The default value is -.

Note: You define and name a schedule using the job schedule cron create command.

[-prefix ] - Snapshot Copy Creation Prefix
This optional parameter specifies the prefix for the Snapshot copy name to be created as per the schedule. If no value is specified, then the snapmirror-label will be used as the prefix. The prefix parameter can only be specified for rules which have a schedule.


So, you could create a yearly cron, add it to the snapmirror policy (using the default MirrorAndVault policy in the example below), and then we've got yearly vaults without needing to have a yearly snapshot on the source:


CL9::> cron create -name yearly -month December -day 31 -hour 23 -minute 55
CL9::> snapmirror policy add-rule -vserver CL9 -policy MirrorAndVault -snapmirror-label yearly -keep 7 -schedule yearly -prefix yearly

Warning: This command will enable scheduled Snapshot copy creation on the destination with SnapMirror label "yearly". Snapshot copies with SnapMirror label "yearly" on the source will not be
         selected for transfer.
Do you want to continue? {y|n}: y


The Test

I want to test this but don’t want to wait 8 years to make sure my 7 year retention is working. So we create:

- cron schedules where a day is one minute, a week is 3 days, a month is 3 weeks, and a year is 3 months
- snapshot policy for the source volume to keep 4 dailys and 2 weeklys
- source and destination volumes
- the snapmirror policy with type vault to keep 4 daily, 2 weekly, 4 monthly, and 7 yearly (note there are no monthlys or yearlys on the source)
- a cron so we can update the snapmirror every “day” (minute)
- the XDP mirror relationship, and finally initialize the snapmirror


cron create DAILY_T -minute  1,2,4,5,7,8,10,11,13,14,16,17,19,20,22,23,25,26,28,29,31,32,34,35,37,38,40,41,43,44,46,47,49,50,52,53,55,56,59
cron create WEEKLY_T -minute 3,6,12,15,21,24,30,33,39,42,48,51,58
cron create MONTHLY_T -minute 9,18,36,45
cron create YEARLY_T -minute 27,54

snapshot policy create -policy 2WEEKS_T -schedule1 DAILY_T -count1 4 -snapmirror-label1 DAILY_T -schedule2 WEEKLY_T -count2 2 -snapmirror-label2 WEEKLY_T -enabled true

volume create -volume VOL001 -vserver SVM1 -aggregate aggr1 -size 1g -space-guarantee none -snapshot-policy 2WEEKS_T
volume create -volume VOL001 -vserver SVM2 -aggregate aggr1 -size 1g -space-guarantee none -type DP

snapmirror policy create -policy 7YEARS_T -type vault -vserver CL9
snapmirror policy add-rule -vserver CL9 -policy 7YEARS_T -snapmirror-label DAILY_T -keep 4
snapmirror policy add-rule -vserver CL9 -policy 7YEARS_T -snapmirror-label WEEKLY_T -keep 2
snapmirror policy add-rule -vserver CL9 -policy 7YEARS_T -snapmirror-label MONTHLY_T -keep 4 -schedule MONTHLY_T -prefix MONTHLY_T
snapmirror policy add-rule -vserver CL9 -policy 7YEARS_T -snapmirror-label YEARLY_T -keep 7 -schedule YEARLY_T -prefix YEARLY_T

cron create EVERY_DAY_T -minute 0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59

snapmirror create -type XDP -policy 7YEARS_T -source-path SVM1:VOL001 -destination-path SVM2:VOL001 -schedule EVERY_DAY_T
snapmirror initialize -destination-path SVM2:VOL001


The Results

Since a year is 27 minutes, in this test world I should have 7 years retention after 189 minutes! Checking backing 4+ hours later, this is what we have on the source volume:


CL9::> volume snapshot show -volume VOL001 -vserver SVM1 -fields snapshot
vserver volume snapshot
------- ------ ------------------------
SVM1    VOL001 WEEKLY_T.2016-12-08_1524
SVM1    VOL001 DAILY_T.2016-12-08_1526
SVM1    VOL001 DAILY_T.2016-12-08_1528
SVM1    VOL001 DAILY_T.2016-12-08_1529
SVM1    VOL001 WEEKLY_T.2016-12-08_1530
SVM1    VOL001 DAILY_T.2016-12-08_1531
6 entries were displayed.


And this is what we have on the destination volume:


CL9::> volume snapshot show -volume VOL001 -vserver SVM2 -fields snapshot
vserver volume snapshot
------- ------ ------------------------
SVM2    VOL001 YEARLY_T.2016-12-08_1227
SVM2    VOL001 YEARLY_T.2016-12-08_1254
SVM2    VOL001 YEARLY_T.2016-12-08_1327
SVM2    VOL001 YEARLY_T.2016-12-08_1354
SVM2    VOL001 YEARLY_T.2016-12-08_1427
SVM2    VOL001 MONTHLY_T.2016-12-08_1436
SVM2    VOL001 MONTHLY_T.2016-12-08_1445
SVM2    VOL001 YEARLY_T.2016-12-08_1454
SVM2    VOL001 MONTHLY_T.2016-12-08_1509
SVM2    VOL001 MONTHLY_T.2016-12-08_1518
SVM2    VOL001 WEEKLY_T.2016-12-08_1524
SVM2    VOL001 YEARLY_T.2016-12-08_1527
SVM2    VOL001 DAILY_T.2016-12-08_1528
SVM2    VOL001 DAILY_T.2016-12-08_1529
SVM2    VOL001 WEEKLY_T.2016-12-08_1530
SVM2    VOL001 DAILY_T.2016-12-08_1531
SVM2    VOL001 DAILY_T.2016-12-08_1532
17 entries were displayed.


Or just the yearly ones (we correctly have 7, even though 8 “years” had passed since the start of the test):

CL9::> volume snapshot show -volume VOL001 -vserver SVM2 -fields snapshot -snapmirror-label "YEARLY_T"
vserver volume snapshot
------- ------ ------------------------
SVM2    VOL001 YEARLY_T.2016-12-08_1227
SVM2    VOL001 YEARLY_T.2016-12-08_1254
SVM2    VOL001 YEARLY_T.2016-12-08_1327
SVM2    VOL001 YEARLY_T.2016-12-08_1354
SVM2    VOL001 YEARLY_T.2016-12-08_1427
SVM2    VOL001 YEARLY_T.2016-12-08_1454
SVM2    VOL001 YEARLY_T.2016-12-08_1527
7 entries were displayed.

As expected, we have monthly and yearly snapshot retention on the vault, but not monthly or yearly snapshots on the source. A great feature in ONTAP 9!

Comments