Software Development Kit (SDK) and API Discussions

Delete snapshot with powershell

peldah
5,744 Views

Hi,

I am trying to delete snapshot from powershell but it does not work for me.

I´m able to connect to my cluster, I can browse vols and snapshots, but follow command just does not work.

I enter my command and nothing happens. No promt or error.

Down below is my command where I try to delete snapshot "hourly.2019-09-26_0805"

 

Get-NcVol snapinfo | Get-NcSnapshot hourly.2019-09-26_0805 | Remove-NcSnapshot

 

I have tried to add  -confirm:$false and it does not make any different.

I make snapshots with SMHV and it does not delete old snapshots, thats is why I have to remove them with a script.

 

Do I need to enable anything on the cluster to allow a script to delete snapshots?

I use Ontap 9.5 SP6 and latest powershell kit for 9.6

 

Br, Pelle Dahlkild

 

I enter m

6 REPLIES 6

Ontapforrum
5,706 Views

Hi,

 

We have lot of examples on the NetApp forums to achieve the same, I just picked one and tested on my lab. It works for me.

 

PS C:\Users\Administrator> Get-Ncvserver SVM_CIFS | get-ncvol vol_CIFS | get-ncsnapshot |? {$_.name -like "hourly.2019-09-27_1505"} | remove-ncsnapshot -Confirm:$False
PS C:\Users\Administrator>

 

If you don't add confirmation, it will prompt you for Y or N

 

Is this what you need ?  Let us know.

peldah
5,531 Views

Hi,

Thanx for you answer.

Yes, that is what I am looking for and also what I am trying to do, but it just dont work.

I found an error in the logfiles from SMHV when it tries to delete the snapshots.

I´ll guess it use PS command also and that is why SMHV cant delete the snapshots either.

Problably some settings in ontap that needs to change or maybe a bug.

 

Br, Pelle

 

[2019-09-27 16:05:46, (92)] Deleting snapshots list...
[2019-09-27 16:05:46, (92)] Processing deletion of backup snapshots..
[2019-09-27 16:05:46, (92)] Deleting snapshot: [Snapshot: vm01_hv-cluster1_SV-SRV-HV01A_09-27-2019_14.05.25_backup,VolumeID: \\sv-svm01\vm01,Storage system: sv-svm1,Volume: scvmm_pool1,LunPath: ]
[2019-09-27 16:05:46, (92)] An error occurred while deleting snapshots SDW returned SnapshotDeleteResult.Snapshot = null

Ontapforrum
5,508 Views

You're welcome.

 

Just to clarify, are you saying the ps command is also not working ? Or, ps command works but SMHV autodeletion as per the policy isn't working ? If ps command is also not working, then we will need to find out if the snap actually exists ?

 

For SMHV unable to delete snapshots, we will need to investigate:

1) Could you list down the snaps on the storage and see if they are still there and hasn't been deleted ?

::> snapshot show -volume scvmm_pool1 -vserver sv-svm1

 

2) Also, give us the snapdrive logs (snapdrive is a key compoennt, SMHV orders SnapDrive to delete snapshots from storage but if SMHV 'snapinfo' isn't sync with Storage volume snaps, there are chances that SMHV will believe these snapshots exists, where as actually they don't.)

 

Note: Ideally, any SnapManager snapshots should never be managed from the filer console.

peldah
5,492 Views

Hi again,

 

1. I have verified and the snapshots is in place.
    Powershell works fine.. just not the "remove" function. But show vols, snapshots and other stuff like that is no problem.

 

2. Where can I find logs on the server.. I have tried to find anything related to my powershell commands, but cant find that.
Here is a post from the logs created by SMHV during failure to delete the snapshots:

Take a look at the line in bold

 

Br, Pelle

 

 

[2019-09-30 13:00:40, (147)] Backup count based retention
[2019-09-30 13:00:40, (147)] Inexcess of backup count: 3
[2019-09-30 13:00:40, (147)] Backups qualifying for deletion:
[2019-09-30 13:00:40, (147)] vm01_09-30-2019_09.00.02
[2019-09-30 13:00:40, (147)] Qualification of backups for retention completed successfully.
[2019-09-30 13:00:40, (147)] Evaluation of backup retention information completed successfully.
[2019-09-30 13:00:40, (147)] Creating backup deletion requests..
[2019-09-30 13:00:40, (147)] Retrieving backup deletion request..
[2019-09-30 13:00:40, (147)] Creation of backup deletion requests completed successfully.
[2019-09-30 13:00:40, (147)] Deleting backups AppInstance Name: hv-cluster1 backup [vm01_09-30-2019_09.00.02] created at 2019-09-30 09:00:02
..
[2019-09-30 13:00:40, (86)] Initializing backup retention policy execution handler..
[2019-09-30 13:00:40, (86)] Initialization of backup retention policy execution handler completed successfully.
[2019-09-30 13:00:40, (86)] Processing deletion of backups..
[2019-09-30 13:00:40, (86)] Retrieving backup information..
[2019-09-30 13:00:40, (86)] processing  backup  backup [vm01_09-30-2019_09.00.02] created at 2019-09-30 09:00:02 for delete
[2019-09-30 13:00:40, (86)] Retrieval of backup information completed successfully.
[2019-09-30 13:00:40, (86)] Retrieving volume group information for the components involved in the backup..
[2019-09-30 13:00:40, (86)] Retrieval of volume group information for the components involved in the backup completed successfully.
[2019-09-30 13:00:40, (86)] Retrieving backup deletion information..
[2019-09-30 13:00:40, (86)] Retrieval of backup deletion information completed successfully.
[2019-09-30 13:00:40, (86)] Deleting backup metadata..
[2019-09-30 13:00:40, (86)] Deleting backup metadata for backup: [vm01_09-30-2019_09.00.02]..
[2019-09-30 13:00:40, (86)] Getting backup metadata for backup: [vm01_09-30-2019_09.00.02]..
[2019-09-30 13:00:40, (86)] Deletion of backup metadata for backup: [vm01_09-30-2019_09.00.02]-Done.
[2019-09-30 13:00:40, (86)] Retrieving volumes qualifying for snapshot deletion based of volume grouping..
[2019-09-30 13:00:40, (86)] Retrieval of volumes qualifying for snapshot deletion based of volume grouping completed successfully.
[2019-09-30 13:00:40, (86)] Retrieving snapshots for deletion..
[2019-09-30 13:00:40, (86)] Retrieval of snapshots for a volume group is completed successfully and added in snapshot list for delete
[2019-09-30 13:00:40, (86)] Deleting all snapshots...
[2019-09-30 13:00:41, (86)] Deleting snapshots list...
[2019-09-30 13:00:41, (86)] Processing deletion of backup snapshots..
[2019-09-30 13:00:41, (86)] Deleting snapshot: [Snapshot: vm01_hv-cluster1_SV-SRV-HV01A_09-30-2019_09.00.02_backup,VolumeID: \\sv-svm01\vm01,Storage system: sv-svm1,Volume: scvmm_pool1,LunPath: ]
[2019-09-30 13:00:41, (86)] An error occurred while deleting snapshots  SDW returned SnapshotDeleteResult.Snapshot = null
[2019-09-30 13:00:41, (86)] Processing deletion of backup snapshots-Done
[2019-09-30 13:00:41, (86)] Deletion of all snapshots completed successfully.
[2019-09-30 13:00:41, (86)] Processing deletion of backups completed successfully.
[2019-09-30 13:00:41, (147)] An error occured while deleting backups.Continuing with rest of the backups.
 An error occurred while processing the delete backups request.
One or more errors occurred.

[2019-09-30 13:00:41, (147)] Processing of backup retention policy completed successfully.
[2019-09-30 13:00:41, (147)] Processing of policy: [Backup Retention policy settings]-Done

 

Ontapforrum
5,487 Views

Could you provide these:

 

SMHV: C:Program Files\NetApp\SnapManager for Hyper-V*.log
SDW: C:Program Files\NetApp\SnapDrive*.log


Also give us the Windows application and system event logs from the box where the SMHV & SDW is installed.

Ontapforrum
5,474 Views

Also will need the following info:

 

 Go to SnapDrive management snap-in:
Could you show me the added storage system: There should be an entry for the SVM [sv-svm01] mentioned in the error log ?

 

Could you send the screenshot.

Public