SnapManager to SnapCenter Transition

SQL script for snapcenter with Where-Object doesnt work

Nikolay3
287 Views

We have an SQL script which deletes a backup from a resource group, deletes clones from that backup, takes a new backup, and takes a new clone from the new backup. This happens each morning. 

 

Since we updated to Snapcenter 5.0 due to a bug the Where-Object BackupName -Match "^A.*" functionality doesn't work. I am listing below the part of the script which fails to define the variables:

 

$oldBack=Get-SmBackup -AppObjectId M4SQLXXXXRO3\M4SQLXXXXRO3\XXX_PROD | Where-Object BackupName -Match "^A.*" | Select-Object -first 1
$oldClone=Get-SmClone -BackupId $oldBack.BackupId

 

NetApp suggests to use Select-String. However, with that I cannot understand how I can define the object. Any ideas how to define an object in Snapcenter 5.0. We understand that this is fixed in 6.0 but it's hard for us to plan an update to that version as all plug-in hosts need to be rebooted to update powershell and .net versions. 

 

I am pasting below some more of the script for reference:

### DELETING PREVIOUS CLONE DB ###

$oldBack=Get-SmBackup -AppObjectId M4SQLXXXXRO3\M4SQLXXXXRO3\XXX_PROD | Where-Object BackupName -Match "^A.*" | Select-Object -first 1
$oldClone=Get-SmClone -BackupId $oldBack.BackupId

Remove-SmClone -CloneName $oldClone.CloneName -PluginCode SMSQL -Confirm:$false

Start-Sleep -Seconds 240

Remove-SmBackup -BackupIds $oldBack.BackupId -Confirm:$false

Start-Sleep -Seconds 240

 

### CREATING NEW BACKUP ###

New-SmBackup -ResourceGroupName XXX_XXXX_Automation -Policy Test

start-sleep -Seconds 300

 

## CREATING THE CLONE ###

$newBack=Get-SmBackup -AppObjectId M4SQLXXXXRO3\M4SQLXXXXRO3\XXX_PROD | Where-Object BackupName -Match "^A.*" | Select-Object -Last 1

New-SmClone -backupname $newBack.BackupName -Resources @{"Host"="XXXXXXXXXX";"Type"="SQL Database";"Names"="M4SQLXXXXRO3\M4SQLXXXXRO3\XXX_PROD"} -CloneToInstance XXXXXXXXX\XXXXXXXXX -AutoAssignMountPoint -CloneName XXX_PROD_SNAP -AppPluginCode SMSQL

1 ACCEPTED SOLUTION

PravinKumar
112 Views

Hi Nikolay,

You shall try the below methods to use Select-String method.

 

$oldBack = Get-SmBackup -AppObjectId M4SQLXXXXRO3\M4SQLXXXXRO3\XXX_PROD | Select-String -Pattern "^A.*" | Select-Object -First 1
$newBack = Get-SmBackup -AppObjectId M4SQLXXXXRO3\M4SQLXXXXRO3\XXX_PROD | Select-String -Pattern "^A.*" | Select-Object -Last 1

 

Regards,

Pravin Kumar

View solution in original post

1 REPLY 1

PravinKumar
113 Views

Hi Nikolay,

You shall try the below methods to use Select-String method.

 

$oldBack = Get-SmBackup -AppObjectId M4SQLXXXXRO3\M4SQLXXXXRO3\XXX_PROD | Select-String -Pattern "^A.*" | Select-Object -First 1
$newBack = Get-SmBackup -AppObjectId M4SQLXXXXRO3\M4SQLXXXXRO3\XXX_PROD | Select-String -Pattern "^A.*" | Select-Object -Last 1

 

Regards,

Pravin Kumar

Public