2010-08-08 04:05 AM
I tried to write a PowerShell script to connect to a filer, and delete all (from the oldest first) but a configurable number of snapshots on all the volumes and aggregates on the filer. I think it was probably too much of a task for my very first powershell scripting attempt. I tried debugging the script using powershell_ise but I am definitely missing a lot on how to use the DataOntap module/calls. Can anyone help?
- connect to filer
- retrieve all vols/aggr
- for every vol/aggr, delete all snapshots from the oldest leaving the most recent $keepsnaps number of snapshots from all vols and all aggregates
2010-08-08 01:18 PM
In the meantime, I have implemented the script in bash.
I am uploading it (delete_all_but_n_snapshots.sh) in case anyone is interested.
I am still interested in a powershell script to do the same.
2010-08-09 06:10 AM
Something to get you started.
$max = 5
foreach ($vol in Get-navol)
$Snapshots = Get-NaSnapshot -Name $vol.name
$remove = $Snapshots.Count - $Max
if ($remove -ge 1)
Sort-Object AccessTime |
Select-Object -First $remove |
2010-08-09 09:29 AM
I need a script to delete snapshots that are more than 30 days old. Our backup software is supposed to do it but it fails every now and then leaving old snapshots on our filers. As I know absolutely nothing about scripting I would really appreciate your help in coming up with a script to meet our needs.
Thanks in advance for your help.