Software Development Kit (SDK) and API Discussions

Snapshot Delete Hourly with Powershell

HUD
NetApp

Hi,

 

Does anyone know how to delete hourly  snapshot or delete  the last  3  snapshot with powershell?

 

Thanks

1 ACCEPTED SOLUTION

GidonMarcus

Hi

 

All hourly:

Import-Module DataONTAP
$CdotCred = Get-Credential
$clustersSessions = Connect-NcController 192.168.0.90 -HTTPS -Credential $CdotCred
$hourlysnap = Get-NcSnapshot -Volume "SAN1_vol1" -Controller $clustersSessions -SnapName "hourly.*"
$hourlysnap
$hourlysnap | Remove-NcSnapshot -Confirm

 

Oldest 3:

Import-Module DataONTAP
$CdotCred = Get-Credential
$clustersSessions = Connect-NcController 192.168.0.90 -HTTPS -Credential $CdotCred
$lastxsnap = Get-NcSnapshot -Volume "SAN1_vol1" -Controller $clustersSessions | sort Created -Descending | select -last 3
$lastxsnap
$lastxsnap | Remove-NcSnapshot -Confirm

 

If you just want to disable the creation of hourly snap on the cluster:

Cdot01::> vol show SAN1_vol1 -fields snapshot-policy
vserver volume    snapshot-policy
------- --------- ---------------
SAN1    SAN1_vol1 default
Cdot01::> snap policy show default
Vserver: Cdot01
                         Number of Is
Policy Name              Schedules Enabled Comment
------------------------ --------- ------- ----------------------------------
default                          3 true    Default policy with hourly, daily & w                                               eekly schedules.
    Schedule               Count     Prefix                 SnapMirror Label
    ---------------------- -----     ---------------------- -------------------
    hourly                     6     hourly                 -
    daily                      2     daily                  daily
    weekly                     2     weekly                 weekly

Cdot01::> snap policy modify-schedule -policy default -schedule hourly -newcount 0                                             0


Cdot01::> snap policy show default
Vserver: Cdot01
                         Number of Is
Policy Name              Schedules Enabled Comment
------------------------ --------- ------- ----------------------------------
default                          3 true    Default policy with hourly, daily & weekly schedules.
    Schedule               Count     Prefix                 SnapMirror Label
    ---------------------- -----     ---------------------- -------------------
    hourly                     0     hourly                 -
    daily                      2     daily                  daily
    weekly                     2     weekly                 weekly

 

Gidi Marcus (Linkedin) - Storage and Microsoft technologies consultant - Hydro IT LTD - UK

View solution in original post

2 REPLIES 2

GidonMarcus

Hi

 

All hourly:

Import-Module DataONTAP
$CdotCred = Get-Credential
$clustersSessions = Connect-NcController 192.168.0.90 -HTTPS -Credential $CdotCred
$hourlysnap = Get-NcSnapshot -Volume "SAN1_vol1" -Controller $clustersSessions -SnapName "hourly.*"
$hourlysnap
$hourlysnap | Remove-NcSnapshot -Confirm

 

Oldest 3:

Import-Module DataONTAP
$CdotCred = Get-Credential
$clustersSessions = Connect-NcController 192.168.0.90 -HTTPS -Credential $CdotCred
$lastxsnap = Get-NcSnapshot -Volume "SAN1_vol1" -Controller $clustersSessions | sort Created -Descending | select -last 3
$lastxsnap
$lastxsnap | Remove-NcSnapshot -Confirm

 

If you just want to disable the creation of hourly snap on the cluster:

Cdot01::> vol show SAN1_vol1 -fields snapshot-policy
vserver volume    snapshot-policy
------- --------- ---------------
SAN1    SAN1_vol1 default
Cdot01::> snap policy show default
Vserver: Cdot01
                         Number of Is
Policy Name              Schedules Enabled Comment
------------------------ --------- ------- ----------------------------------
default                          3 true    Default policy with hourly, daily & w                                               eekly schedules.
    Schedule               Count     Prefix                 SnapMirror Label
    ---------------------- -----     ---------------------- -------------------
    hourly                     6     hourly                 -
    daily                      2     daily                  daily
    weekly                     2     weekly                 weekly

Cdot01::> snap policy modify-schedule -policy default -schedule hourly -newcount 0                                             0


Cdot01::> snap policy show default
Vserver: Cdot01
                         Number of Is
Policy Name              Schedules Enabled Comment
------------------------ --------- ------- ----------------------------------
default                          3 true    Default policy with hourly, daily & weekly schedules.
    Schedule               Count     Prefix                 SnapMirror Label
    ---------------------- -----     ---------------------- -------------------
    hourly                     0     hourly                 -
    daily                      2     daily                  daily
    weekly                     2     weekly                 weekly

 

Gidi Marcus (Linkedin) - Storage and Microsoft technologies consultant - Hydro IT LTD - UK

View solution in original post

HUD
NetApp

Thanks Marcus

Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public