<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: What is the easiest way to update the snapshot policy for hundreds of volumes? in ONTAP Discussions</title>
    <link>https://community.netapp.com/t5/ONTAP-Discussions/What-is-the-easiest-way-to-update-the-snapshot-policy-for-hundreds-of-volumes/m-p/454448#M43853</link>
    <description>&lt;P&gt;ok, do you know how to delete lots of snapshots according to age?&lt;/P&gt;</description>
    <pubDate>Tue, 13 Aug 2024 08:16:28 GMT</pubDate>
    <dc:creator>Northman</dc:creator>
    <dc:date>2024-08-13T08:16:28Z</dc:date>
    <item>
      <title>What is the easiest way to update the snapshot policy for hundreds of volumes?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/What-is-the-easiest-way-to-update-the-snapshot-policy-for-hundreds-of-volumes/m-p/454424#M43846</link>
      <description>&lt;P&gt;I am thinking to look for a powercli command that does this and then prepare a long list of the command for each volume, using Excel and notepad. And then copy the commands in 10 at the time?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;also need to delete hundreds of old snapshots in those volumes. How can I do this? Is there a time switch I can use with a powershell command that lets me delete all snapshots older than 4 weeks for instance?&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2024 12:36:54 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/What-is-the-easiest-way-to-update-the-snapshot-policy-for-hundreds-of-volumes/m-p/454424#M43846</guid>
      <dc:creator>Northman</dc:creator>
      <dc:date>2024-08-12T12:36:54Z</dc:date>
    </item>
    <item>
      <title>Re: What is the easiest way to update the snapshot policy for hundreds of volumes?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/What-is-the-easiest-way-to-update-the-snapshot-policy-for-hundreds-of-volumes/m-p/454426#M43847</link>
      <description>&lt;P&gt;If there’s lots of similarity, use an extended query&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;vol modify {-vserver xxx -snapshot-policy old_policy} -snapshot-policy new_policy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;find all volumes in svm xxx with snapshot policy old_policy and replace it with new_policy&lt;/P&gt;</description>
      <pubDate>Mon, 12 Aug 2024 13:36:45 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/What-is-the-easiest-way-to-update-the-snapshot-policy-for-hundreds-of-volumes/m-p/454426#M43847</guid>
      <dc:creator>TMACMD</dc:creator>
      <dc:date>2024-08-12T13:36:45Z</dc:date>
    </item>
    <item>
      <title>Re: What is the easiest way to update the snapshot policy for hundreds of volumes?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/What-is-the-easiest-way-to-update-the-snapshot-policy-for-hundreds-of-volumes/m-p/454448#M43853</link>
      <description>&lt;P&gt;ok, do you know how to delete lots of snapshots according to age?&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2024 08:16:28 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/What-is-the-easiest-way-to-update-the-snapshot-policy-for-hundreds-of-volumes/m-p/454448#M43853</guid>
      <dc:creator>Northman</dc:creator>
      <dc:date>2024-08-13T08:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: What is the easiest way to update the snapshot policy for hundreds of volumes?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/What-is-the-easiest-way-to-update-the-snapshot-policy-for-hundreds-of-volumes/m-p/454465#M43856</link>
      <description>&lt;P&gt;Hey Northman,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You will need to compare the snapshot creation date to the current date to calculate the snapshot age. Here's a script that will calculate the snapshot age based on a retention variable in days and display the commands that you "would" run if you wanted to delete the snapshots. I'd advise you thoroughly check the results "before" you delete any snapshots. Note that this explicitly filters out any snapshots used for SnapMirror baseline transfers.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Param(
   [Parameter(Mandatory = $True, HelpMessage = "The cluster name or IP Address")]
   [String]$Cluster,
   [Parameter(Mandatory = $True, HelpMessage = "The number of Days to retain the snapshots")]
   [Int]$RetentionDays,
   [Parameter(Mandatory = $True, HelpMessage = "The Credential to authenticate to ONTAP")]
   [System.Management.Automation.PSCredential]$Credential
)
#'------------------------------------------------------------------------------
#'Connect to the cluster.
#'------------------------------------------------------------------------------
Try{
   Connect-NcController -Name $Cluster -Credential $Credential | Out-Null
}Catch{
   Write-Warning -Message $("Failed connecting to cluster ""$Cluster"". Error " + $_.Exception.Message)
   Exit -1
}
#'------------------------------------------------------------------------------
#'Enumerate all Snapshots.
#'------------------------------------------------------------------------------
Try{
   $snaps = Get-NcSnapshot -ErrorAction Stop
}Catch{
   Write-Warning -Message $("Failed Enumerating Snapshots on Cluster ""$Cluster"". Error " + $_.Exception.Message)
   Exit -1
}
#'------------------------------------------------------------------------------
#'Filter out any snapshots with dependancies for SnapMirror etc.
#'------------------------------------------------------------------------------
$snapshots   = $snaps | Where-Object {$_.Dependency -eq $Null}
$currentDate = Get-Date
$retention   = $($RetentionDays * (60 * 60 * 24))
#'------------------------------------------------------------------------------
#'Display the command to delete the snapshot.
#'------------------------------------------------------------------------------
ForEach($snapshot In $snapshots){
   $created = Get-Date -Date $snapshot.Created
   $age     = New-TimeSpan -Start $created -End $currentDate
   If($age.TotalSeconds -ge $retention -And $snapshot.Name -notlike "snapmirror.*"){
      Write-Host $("snapshot delete -vserver " + $snapshot.Vserver + " -volume " + $snapshot.Volume + " -snapshot " + $snapshot.Name)
   }
}
#'------------------------------------------------------------------------------&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Usage:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;PS C:\Scripts\PowerShell\Projects\DeleteAgedSnapshots&amp;gt; $Credentials = Get-Credential
PS C:\Scripts\PowerShell\Projects\DeleteAgedSnapshots&amp;gt; .\DeleteAgedSnapshots.ps1 -Cluster cluster1.testlab.local -RetentionDays 7 -Credential $Credentials&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope that gives you some ideas. It wouldn't be much effort to add the code to delete the snapshots&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;/Matt&lt;/P&gt;</description>
      <pubDate>Wed, 14 Aug 2024 04:39:43 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/What-is-the-easiest-way-to-update-the-snapshot-policy-for-hundreds-of-volumes/m-p/454465#M43856</guid>
      <dc:creator>mbeattie</dc:creator>
      <dc:date>2024-08-14T04:39:43Z</dc:date>
    </item>
    <item>
      <title>Re: What is the easiest way to update the snapshot policy for hundreds of volumes?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/What-is-the-easiest-way-to-update-the-snapshot-policy-for-hundreds-of-volumes/m-p/454517#M43865</link>
      <description>&lt;P&gt;Ho do you run an extended query for this? I thought an extended query was of the form:&amp;nbsp;volume show -fields volume, size -query 'size &amp;gt;= 100GB &amp;amp;&amp;amp; size &amp;lt;= 1TB'&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 12:11:21 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/What-is-the-easiest-way-to-update-the-snapshot-policy-for-hundreds-of-volumes/m-p/454517#M43865</guid>
      <dc:creator>Northman</dc:creator>
      <dc:date>2024-08-15T12:11:21Z</dc:date>
    </item>
    <item>
      <title>Re: What is the easiest way to update the snapshot policy for hundreds of volumes?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/What-is-the-easiest-way-to-update-the-snapshot-policy-for-hundreds-of-volumes/m-p/454518#M43866</link>
      <description>&lt;P&gt;Not sure where you got that idea. From the docs:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.netapp.com/us-en/ontap/system-admin/methods-extended-queries-concept.html" target="_blank"&gt;https://docs.netapp.com/us-en/ontap/system-admin/methods-extended-queries-concept.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 12:57:31 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/What-is-the-easiest-way-to-update-the-snapshot-policy-for-hundreds-of-volumes/m-p/454518#M43866</guid>
      <dc:creator>TMACMD</dc:creator>
      <dc:date>2024-08-15T12:57:31Z</dc:date>
    </item>
    <item>
      <title>Re: What is the easiest way to update the snapshot policy for hundreds of volumes?</title>
      <link>https://community.netapp.com/t5/ONTAP-Discussions/What-is-the-easiest-way-to-update-the-snapshot-policy-for-hundreds-of-volumes/m-p/454524#M43867</link>
      <description>&lt;P&gt;something like&lt;/P&gt;&lt;P&gt;::&amp;gt;volume snapshot delete {-vserver * - volume * -create-time &amp;lt;10d} -force true&lt;BR /&gt;this command will delete ALL snapshots within the cluster older that 10 days without asking for confirmation&lt;BR /&gt;Please be careful with that&lt;BR /&gt;basically inside the brackets is&lt;BR /&gt;volume snapshot show -vserver * -volume * -create-time&amp;lt;10d&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;So before deleting&amp;nbsp; anything try first to create a correct command to show needed age snapshots for specific vserver\volume&lt;BR /&gt;Also don't use -force true option in deleting - then for every snapshot to be deleted cli will require you to hit yes&lt;BR /&gt;In a scenario where you are not sure better to not use -force&lt;BR /&gt;In a scenario you are planning to delete thousands of snapshots it might be painful to hit yes thousands of times&lt;BR /&gt;&lt;BR /&gt;explanation of how extended queries work&lt;BR /&gt;&lt;A href="https://docs.netapp.com/us-en/ontap/system-admin/methods-extended-queries-concept.html" target="_blank"&gt;https://docs.netapp.com/us-en/ontap/system-admin/methods-extended-queries-concept.html&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Also very nice article - it is quite old but still usefull!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://whyistheinternetbroken.wordpress.com/2015/02/16/techbecome-a-clustered-data-ontap-cli-ninja/" target="_blank"&gt;https://whyistheinternetbroken.wordpress.com/2015/02/16/techbecome-a-clustered-data-ontap-cli-ninja/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 15:10:40 GMT</pubDate>
      <guid>https://community.netapp.com/t5/ONTAP-Discussions/What-is-the-easiest-way-to-update-the-snapshot-policy-for-hundreds-of-volumes/m-p/454524#M43867</guid>
      <dc:creator>Sergey_Osipov</dc:creator>
      <dc:date>2024-08-15T15:10:40Z</dc:date>
    </item>
  </channel>
</rss>

