NetApp Community Update
This site will enter Read Only mode on July 23 as we prepare to move to a new platform. You will still be able to view content, but posting and replying will be temporarily disabled.
We're excited to launch our new Community experience on July 30 and more information will follow soon.
Stay connected during the transition - Join our Discord community today.

Data Protection

SnapDrive snapshots with snapmirror label

Rapp
4,220 Views

I need to get an application consistant snapshot of an RDM volume, which I am during by running the following script to take a weekly backup of the D drive on a server. The only problem with this is I don't seem to be able to apply a snapmirror label to the snapshot. I can't seem to find an option to do this using the sdcli commands.

 

sdcli snap create -s sd_weekly.0 -D d -u
sdcli snapvault archive -force -a sd_weekly_%DATE:~6,4%%DATE:~3,2%%DATE:~0,2% -DS d sd_weekly.0
sdcli snap delete -D d -s sd_weekly.1
sdcli snap rename -d d -o sd_weekly.0 -n sd_weekly.1

 

So I have written the following powershell script to apply a snapmirror label to the snapshot, which works but when I run the last command to return the results it doesn't do so.

 

Import-Module DataONTAP

Connect-NcController -name Filer1

$q = Get-NcSnapshot -Template

$q.Name = "sd_weekly.0"

$a = Get-NcSnapshot -Template

$a.SnapmirrorLabel = "Weekly"

Get-NcSnapshot -Volume server01_d -SnapName sd_weekly.0 | Update-NcSnapshot -Query $q -Attributes $a

Get-NcSnapshot -Volume server01_d -SnapName sd_weekly.0 | Select-Object Volume,SnapmirrorLabel

 

However if I run the following from putty on the filer1 it does show that it has updated the snapmirror label

 

 snapshot show -vserver SVM01 -volume server01_d -fields snapmirror-label

 

Does anyone have any idea's on how I can get this to update correctly in powershell??

 

 

 

1 REPLY 1

grahame
4,052 Views

Not sure if this will help a script i did years ago where before there was snapmirror integration in SME i highlighted the command in orange i was running to add the label

 

###########################################################################
### IMPORT NETAPP DATAONTAP TOOLKIT

if((Get-Module -Name "DataOntap") -eq $Null){
Import-Module -Name DataONTAP
Write-Host "Module DataONTAP imported"
}

 

###########################################################################
### CONNECT TO Cluster vserver

### add password to file location can be whatever you want
$username = "vsadmin"
$password = convertto-securestring "netapp1" -AsPlainText -force
$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
$Controller = "10.10.10.178"

Connect-NcController -Name $Controller -Credential $cred -HTTPS -Vserver sonetapp7

###########################################################################
### PREDEFINED SNAPMIRROR LABEL

$SnapmirrorLabel = "EXCH_DAILY"


###########################################################################
### GET VOLUME LIST EXCHANGE VOLUMES

$EXCH_Volumes = Get-NcVol | Where-Object {$_.Name -like "soexch*"}

for($i = 0;$i -lt $EXCH_Volumes.Length; $i++){

$UpdateSnapVault = $False
$VolumeSnapshot = Get-NcSnapshot -Volume $EXCH_Volumes[$i].Name | Where-Object {$_.Name -like "exchsnap*"} | sort descending

if(($VolumeSnapshot[0].Name -like "exchsnap*") -and ($VolumeSnapshot[0].SnapmirrorLabel -eq $Null) ){


$UpdateSnapVault = $True

Set-NcSnapshot -Vserver $EXCH_Volumes[$i].Vserver -Volume $EXCH_Volumes[$i].Name -Snapshot $VolumeSnapshot[0].Name -SnapmirrorLabel $SnapmirrorLabel

if($UpdateSnapVault -eq $True){

$SnapmirrorRelation = $Null
$SnapmirrorRelation = Get-NcSnapmirror -SourceVolume $EXCH_Volumes[$i].Name
Invoke-NcSnapmirrorUpdate -Source $SnapmirrorRelation.SourceLocation -Destination $SnapmirrorRelation.DestinationLocation

}

}

}

 

Public