Just had someone ask me how they can delete all snapshots on a volume in cdot without being prompted for each snapshot to authorize it. (Shoutz to Tonyz for asking this on IRC)
I told them powershell. Here’s a quick illustration of how to do it.
(Go here and update or install the latest version of the toolkit. http://mysupport.netapp.com/NOW/download/tools/powershell_toolkit/ )
Notice: See how “Na” has been replaced with “Nc” on many of these?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
PS C:\Users\jk-47> Import-Module DataOntap PS C:\Users\jk-47> Connect-NcController 192.168.1.232 Name Address Vserver Version ---- ------- ------- ------- 192.168.1.232 192.168.1.232 NetApp Release 8.2.1 Cluster-Mode: Fri Mar 21 18:39:00 P #Get My list of volumes to test with PS C:\Users\jk-47> get-ncvserver demo_cifs | get-ncvol Name State TotalSize Used Available Dedupe Aggregate Vserver ---- ----- --------- ---- --------- ------ --------- ------- demo_cifs_root online 1.0 GB 5% 972.5 MB False aggr1_c2_2tb_fp demo_cifs snaptest_vol online 100.0 GB 0% 100.0 GB False aggr1_c2_2tb_fp demo_cifs # Ill just use my root since it has snaps on it. Let's get info about it PS C:\Users\jk-47> get-ncvserver demo_cifs | get-ncvol demo_cifs_root Name State TotalSize Used Available Dedupe Aggregate Vserver ---- ----- --------- ---- --------- ------ --------- ------- demo_cifs_root online 1.0 GB 5% 972.5 MB False aggr1_c2_2tb_fp demo_cifs # Let's get my list of snaps on this volume to make sure I have some to delete PS C:\Users\jk-47> get-ncvserver demo_cifs | get-ncvol demo_cifs_root | Get-NcSnapshot Name Volume Vserver Created Total Cumulative Dependency ---- ------ ------- ------- ----- ---------- ---------- hourly.2014-06-27_1005 demo_cifs_root demo_cifs 6/27/2014 128.0 KB 1.3 MB hourly.2014-06-27_1105 demo_cifs_root demo_cifs 6/27/2014 164.0 KB 1.2 MB hourly.2014-06-27_1205 demo_cifs_root demo_cifs 6/27/2014 164.0 KB 1.1 MB hourly.2014-06-27_1305 demo_cifs_root demo_cifs 6/27/2014 168.0 KB 912.0 KB hourly.2014-06-27_1405 demo_cifs_root demo_cifs 6/27/2014 128.0 KB 744.0 KB hourly.2014-06-27_1505 demo_cifs_root demo_cifs 6/27/2014 216.0 KB 616.0 KB snapshot_27062014_115001 demo_cifs_root demo_cifs 6/27/2014 68.0 KB 400.0 KB snapshot_27062014_115005 demo_cifs_root demo_cifs 6/27/2014 88.0 KB 332.0 KB snapshot_27062014_115009 demo_cifs_root demo_cifs 6/27/2014 80.0 KB 244.0 KB snapshot_27062014_115013 demo_cifs_root demo_cifs 6/27/2014 92.0 KB 164.0 KB omgbbq demo_cifs_root demo_cifs 6/27/2014 72.0 KB 72.0 KB # Ok since I am passing Snaps as objects I can pipe it into a remove commandlet to purge them all out. PS C:\Users\jk-47> get-ncvserver demo_cifs | get-ncvol demo_cifs_root | Get-NcSnapshot | remove-ncsnapshot Delete snapshot Are you sure you want to delete snapshot hourly.2014-06-27_1005 from volume demo_cifs_root? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): A # I just told it to say Yes to All |
The toolkit lacks a -confirm/-confirm:$false or a -force flag so you will be prompted once, but it is better than a prompt for each snap.
Hope this helps someone out.
Comments are closed.