Subscribe

using Powershell, Deleting old snapshots

Using powershell, can we find out the year,month,date of the snapshots under each volume and delete only the old snapshots > 120 days old.

Re: using Powershell, Deleting old snapshots

You can try something like this.

 

#Set a new variable of date type which is 120 days before the current date

$120days = (get-date).adddays(-120)

 

#Get list of all snapshots older than 120 days and delete them ( i have put an whatif parameter to check and confirm) 

Get-Ncvol | Get-NcSnapshot | where-object { $_.created -lt $120days } | remove-ncsnapshot -whatif

Re: using Powershell, Deleting old snapshots

Thanks for quick response. sorry to trouble with few more questions.. Smiley Happy

 

1)  if we run the PS script from Oncommand /DFM server against the filer, does it use dfm based user account ? or we need to supply filer accounts explicitly?

2) Already have PS installed in the server,Do we need to have admin rights in the windows server to add the Data ontap PS modules?

3) is there anyway we can ignore deletion of mirror and snapvault base snapshots eventhough older?

Re: using Powershell, Deleting old snapshots

[ Edited ]

Hello Siva,

 

Answers below.

 

1)  if we run the PS script from Oncommand /DFM server against the filer, does it use dfm based user account ? or we need to supply filer accounts explicitly?

You need to supply the filer accounts to establish connection 

 

2) Already have PS installed in the server,Do we need to have admin rights in the windows server to add the Data ontap PS modules?

Yes you would need admin rights to install pstoolkit.

 

3) is there anyway we can ignore deletion of mirror and snapvault base snapshots eventhough older?

You would need to filter out these snapshots by their naming conventions.

 

Thanks,

Vinith

 

Please remember to mark solved if you feel your query is answered.

Re: using Powershell, Deleting old snapshots

I see Vinith has given you the cDot cmdlets.. Are you running cDot or 7-mode..

 

Also - I've written something that will report on your entire environment, not delete, that is easy to add..

Re: using Powershell, Deleting old snapshots

Thanks we are using 7 mode.

 

 

 

 

 

Re: using Powershell, Deleting old snapshots

Siva then you would need to replace "Nc" with "Na" in the example i gave you, all 7-Mode cmdlets are of type "Na" and "Nc" is for cDOT

Re: using Powershell, Deleting old snapshots

Also, you want to query non-snapmirrored volumes, since you can't delete snaps on read-only volume.

 

I'll start you with this query

 

Get-NaVol | ? {$_.state -eq "online" -and $_.raidstatus -notmatch "read-only"} 

 

 

Re: using Powershell, Deleting old snapshots

I have two NetApp Clustered OnTAP sites with SnapVault relationships running between them.  I am using SMVI at both sites to create crash consistent backups of my VM's contained within the volumes/datastores and then SnapVault them cross-site.  In order for the SnapVault to work I need to have SnapShots enabled.  The labels are configured as VSC_DAILY_BACKUP and VSC_WEEKLY_BACKUP.  By doing this however this creates daily and weekly 'non-crash-consistent' snapshots.  The only snapshots that I need are the SMVI daily and SMVI weekly ones.  I suspect that I am unable to get away from having the normal NetApp volume snapshots (daily, weekly).  Is there a post backup script that can be run for each SMVI backup job that lists and deletes all non-smvi snapshots?