Powershell script to age out Netapp snapshots
I had a an incident where i had to recreate the SMVI jobs on one of our Filers , we have a requirement to keep 26 days of backups online.
As always space was at a premium so What i wanted to do was to delete the old version of the SMVI
Snapshot each time after the new snapshot was taken...
so i created a script which loops through decreasing the value of the number of backups we want to keep
$days = -26
for ($loops = 26;$loops -ge 0; $loops --)
{
$BackupstoKeep = (get-date).adddays($days)
Connect-nacontroller "Filer1"
Get-Navol | Get-NaSnapshot | where-object { $_.name -like "smvi_*" -and $_.created -lt $Backupstokeep } | remove-nasnapshot
Connect-nacontroller "Filer2"
Get-Navol | Get-NaSnapshot | where-object { $_.name -like "smvi_*" -and $_.created -lt $Backupstokeep } | remove-nasnapshot
$days++
Start-sleep 86400
}
No comments:
Post a Comment