SnapManager to SnapCenter Transition

Finding the oldest snapshot by volume

Ace
834 Views

I'm running into an issue where snapshots older than the Snapcenter retention period are not always removed, and I would like to run a powershell script to check for these (and possibly delete anything older. )

 

This is SQL server FC attached vols, and the SnapCenter workflow is 1) full-backup with 7 days retention -> 2) snapmirror copy also with 7 days retention -> 3) snapvault copy to a separate aggr with 14 days retention.

 

To check the snapshot dates in chronological order, I am running:

Get-NcSnapshot | Where-Object {$_.Volume -match 'sql_srv_volx'} | Sort-object -property Created

 

This is reporting all dates for the relevant volumes, but is it possible to show the oldest snapshot only?  I've tried variations of -CreateTime >7days, but must be doing something wrong. 

1 ACCEPTED SOLUTION

psx
NetApp
755 Views

I am no PowerShell guru, but this seems to work (snapshots older than 55 days):

 

PS > Get-NcSnapshot -ontapi | Sort-Object -Property Created | ? { $_.Created -lt (Get-Date).AddDays(-55) }

Name                      Volume               Vserver                   Created      Total Cumulative Dependency
----                      ------               -------                   -------      ----- ---------- ----------
snapmirror.xxxxxxxx-x2... xxxx_xxxx            xxxxxxxx                  01.05.2023   264,0 KB   264,0 KB snapmirror
xxx_daily.2023-10-2...    xxxx_xxxx            xxxxxxxx                  23.10.2023   252,0 KB   252,0 KB
xxx_daily.2023-10-2...    xxxx_xxxx            xxxxxxxx                  27.10.2023   272,0 KB   524,0 KB
xxx_daily.2023-10-2...    xxxx_xxxx            xxxxxxxx                  29.10.2023   340,0 KB   864,0 KB

View solution in original post

2 REPLIES 2

psx
NetApp
756 Views

I am no PowerShell guru, but this seems to work (snapshots older than 55 days):

 

PS > Get-NcSnapshot -ontapi | Sort-Object -Property Created | ? { $_.Created -lt (Get-Date).AddDays(-55) }

Name                      Volume               Vserver                   Created      Total Cumulative Dependency
----                      ------               -------                   -------      ----- ---------- ----------
snapmirror.xxxxxxxx-x2... xxxx_xxxx            xxxxxxxx                  01.05.2023   264,0 KB   264,0 KB snapmirror
xxx_daily.2023-10-2...    xxxx_xxxx            xxxxxxxx                  23.10.2023   252,0 KB   252,0 KB
xxx_daily.2023-10-2...    xxxx_xxxx            xxxxxxxx                  27.10.2023   272,0 KB   524,0 KB
xxx_daily.2023-10-2...    xxxx_xxxx            xxxxxxxx                  29.10.2023   340,0 KB   864,0 KB

Ace
611 Views

Thanks, this was helpful in piecing together my final script.

Public