Quantcast
Channel: ONTAP Discussions topics
Viewing all articles
Browse latest Browse all 4880

Using powershell to enabled scheduled snapshots

$
0
0

I can't seem to get scheduled snapshots enabled through powershell. I can assign a policy, but auto snapshots is not enabling, the below script says its sucessful, but the box remains unchecked and no snapshots are created. I tried setting nosnap directly but that says

 

Set-NcVolOption : Modification of the following fields: auto-snapshots-enabled not allowed for volumes of the type "Flexible Volume - Read-Write volume".

At line:1 char:1

+ Set-NcVolOption -Key "nosnap" -Value "off" -Name UCS_SAS_APP02_PROD01 ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (172.25.200.217:NcController) [Set-NcVolOption], EONTAPI_EVOLOPNOTSUPP

    + FullyQualifiedErrorId : ApiException,DataONTAP.C.PowerShell.SDK.Cmdlets.Volume.SetNcVolOption

 

Is there a way to do this? Below is the code I'm using.

 

$vols=Get-NcVol | ?{
# get non-root volumes
$_.VolumeStateAttributes.IsNodeRoot -eq $false `
-and
# which are rw (this will exclude SnapMirror, etc.)
$_.VolumeIdAttributes.Type -eq "rw" `
-and
(
# with "nosnap" turned on
(($_ | Get-NcVolOption -Hashtable).value.nosnap -eq "on") `
-or
# or with snapshot policy set to Target Policy
($_.VolumeSnapshotAttributes.SnapshotPolicy -eq "Daily_SS")
)
}

foreach($vol in $vols)
{
$volName=$vol.Name
$policyName="Daily_SS"
$query = @{
Name = $volName
}

$attributes = @{
VolumeSnapshotAttributes = @{
SnapshotPolicy = $policyName
}
}

$a=Get-NcVol -Template
Initialize-NcObjectProperty $a VolumeSnapshotAttributes

$a.VolumeSnapshotAttributes.AutoSnapshotsEnabled=$true

Update-NcVol -Query $query -Attributes $a


}


Viewing all articles
Browse latest Browse all 4880

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>