Microsoft Virtualization Discussions

Powershell command for adding existing snapshot policy to a volume -

NwkThd_04
2,666 Views

Hello Team, 

 

Anyone please help me to find the command  for adding  existing snapshot policy to a volume 

 

I have tried with  " get-ncvol volume name  -Vserver  vserver name   |  Set-NcSnapshotPolicy   policy name" but failed 

 Also  I was trying  update-ncvol  as well , but could not  find snapshotpolicy name option there.

it looks like I am not using the current context?

I am using powershell tool kit 9.8.xx 

Thanking you in advance.

 

Regards,

 

Shyju.

2 REPLIES 2

ajeffrey
2,577 Views

Hi There

I was able to get this to work but only after creating a snapshot policy with a scope of the particular Storage VM

Screen Shot 2021-07-02 at 10.55.11 AM.png

PS C:\Users\Administrator> Get-NcVol -Vserver FP-Test | Set-NcSnapshotPolicy -Name test

Policy Enabled SnapshotPolicySchedules
------ ------- -----------------------
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}
test True {hourly (0), daily (0), weekly (1)}

rafael-miranda
20 Views

Hello. I don't mean to necropost, but since I had the same need and didn't find a comprehensive answer, here's an example that worked using "Update-NcVol" with version 9.15.1.2410 of the NetApp.ONTAP module.

 

# The $querytemplate variable will be used to specify which volumes should be modified. The example specifies a specific vserver and a simple regex to match 3 volume names. You can change this to suit your environment.
$querytemplate = Get-NcVol -Template
$querytemplate.Vserver = "vserver-name"
$querytemplate.Name = "vol1|vol2|vol3"

# The $attrib variable will specify the snapshot policy to be set on the volumes that match the criteria defined in the $querytemplate variable.
$attrib = Get-NcVol -Template
Initialize-NcObjectProperty -Object $attrib -Name VolumeSnapshotAttributes
$attrib.VolumeSnapshotAttributes.SnapshotPolicy = "snap_policy"

# This will effectively change the snapshot policy on the volumes. The '-ONTAPI' parameter is used so that ZAPI is used instead of the REST API, which is the default in this version of the module.
Update-NcVol -Query $querytemplate -Attributes $attrib -ONTAPI

 

Public