The NetApp Community is moving to a new platform and is in Read-Only mode. Click to learn more.
Stay connected during the transition - Join our Discord community today.

Software Development Kit (SDK) and API Discussions

Snapshot Delete Hourly with Powershell

HUD
NetApp
3,909 Views

Hi,

 

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

 

Thanks

1 ACCEPTED SOLUTION

GidonMarcus
3,835 Views

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
3,836 Views

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

HUD
NetApp
3,816 Views

Thanks Marcus

Public