ONTAP Discussions

Need help from a Powershell expert on this snapmirror command

Northman
3,779 Views

SYNTAX

    Invoke-NcSnapmirrorInitialize [-DestinationCluster <String>] -DestinationVserver <String> -DestinationVolume <String> [-SourceCluster <String>] [-SourceVserver <String>] [-SourceVolume <String>] [-MaxTransferRat

    e <Int64>] [-TransferPriority <String>] [-SourceSnapshot <String>] [-Passthru] [-IsAutoExpandEnabled <Boolean>] [-IsAdaptive <Boolean>] [-IsCatalogEnabled <Boolean>] [-Controller <NcController[]>] [-InformationA

    ction <ActionPreference>] [-InformationVariable <String>] [-PipelineVariable <String>] [-ZapiRetryCount <Int32>] [<CommonParameters>]

 

I am connected to one of the nodes on the SNAPVAULT cluster (as well as the source and destination vservers):

 

PS H:\> Connect-NcController SNAPVAULT-i-svc01-01  -Credential (Get-Credential)

 

cmdlet Get-Credential at command pipeline position 1

Supply values for the following parameters:

Credential

 

Name                 Address           Vserver              Version

----                 -------           -------              -------

SNAPVAULT-i-svc01-01       X.Y.63.205                           NetApp Release 9.11.1P8: Fri Apr 07 00:02:50 UTC 2023

 

But, when running the command below, I get an error about wrong credentials. Anyone can explain why? 

 

PS H:\> invoke-NCSnapmirrorInitialize -DestinationCluster X.Y.63.209 -DestinationVserver svm_cifs_filer_DD_PROD_SM_Test

-DestinationVolume Backup -SourceCluster X.Y.63.102 -SourceVserver svm_cifs_filer_DD_PROD:Backup -SourceVolume Backup -Controller SNAPVAULT-i-svc01-01

 

invoke-NCSnapmirrorInitialize : Incorrect credentials for SNAPVAULT-i-svc01-01.

At line:1 char:1

+ invoke-NCSnapmirrorInitialize -DestinationCluster X.Y.63.209 -Desti ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (SNAPVAULT-i-svc01-01:NcController) [Invoke-NcSnapmirrorInitialize], NaAuthException

    + FullyQualifiedErrorId : ApiException,DataONTAP.C.PowerShell.SDK.Cmdlets.Snapmirror.InvokeNcSnapmirrorInitialize

 

Here is what help -full describes about -Controller parameter:

 

    -Controller <NcController[]>

        A clustered Data ONTAP controller to receive this cmdlet, as embodied by an NcController object.  This parameter is returned by the Connect-NcController cmdlet.  If not specified, the value in the global var

        iable CurrentNcController is used.  In the latter case, if CurrentNcController contains a collection of NcController objects, this cmdlet is invoked on each controller in succession.

 

        Required?                    false

        Position?                    named

        Default value

        Accept pipeline input?       true (ByValue, ByPropertyName)

        Accept wildcard characters?  False

 

 

 

 

10 REPLIES 10

Sanaman
3,716 Views

Are you connecting to source filer or destination (snapmirror)filer? SNapmirror commands are run on destination filer.

Northman
3,709 Views

I am running it from my admin desktop. The script specifies both source and destination. How can I run this script from the destination?

Sanaman
3,706 Views

Yes, you are running PS script from from admin/windows server. But, you will need to connect to the destination cluster .

 

Connect-NcController  -Destination-Cluster

 

Connect-NcController <destination-cluster>
Scripts> Connect-NcController cluster1

Windows PowerShell Credential Request
Enter your credentials.
User: domain\user
Password for user domain\user: *************


Name Address Vserver Version
---- ------- ------- -------
cluster1 xx:xxx:xx:xxx.... NetApp Release 9.11.1P8: Fri Apr 07 00:02:50 UTC 2023

PS C:\Scripts> get-NcCluster

ClusterContact : support@mydomain.com
ClusterLocation : Domain Prod2
ClusterName : cluster1
ClusterSerialNumber :
ClusterUuid : xxxxxxxxxx....
NcController : cluster1

......

 

\Scripts> Get-NcSnapmirror

SourceLocation DestinationLocation Status MirrorState
-------------- ------------------- ------ -----------
svmnfsp01:svmnfsp01_prod_store1 svmnvp61:svmnfsp01_prod_store1_vault snapmirrored snapmirrored
svmnfst21:svmnfst21_non_prod_store1 svmnvp61:svmnfst21_non_prod_store1_vault snapmirrored snapmirrored
svmncifp01:DFS_GRP svmnvp61:svmncifp01_DFS_GRP_vault snapmirrored snapmirrored

......

 

Hope that helps.

Northman
3,703 Views

Yes, I was connected to the destination cluster as well. I have skipped doing this with just powershell commands.  need to get this working with a Excel input-file. I am using the below script using a input-file, but it halts. Any ideas?

 

Script with errors (the variables have been defined using :$exelPath and $inputdata = Import-Excel -path $exelPath

 

PS H:\> foreach ($row in $inputData) {

>> $srcClusterIP = $row.'Source Cluster IP'

>> $srcSVM = $row.'Source SVM'

>> $srcVolume = $row.'Source Volume'

>> $dstClusterIP = $row.'Destination Cluster IP'

>> $dstSVM = $row.'Destination SVM'

>> $dstVolume = $row.'Destination Volume'

>> 

>> # Connect to source and destination clusters

>> Connect-NcController -Name $srcClusterIP

>> Connect-NcController -Name $dstClusterIP

>> 

>> # Create SnapMirror relationship

>> Initialize-NcSnapMirror -SourcePath $srcSVM:$srcVolume -DestinationPath $dstSVM:$dstVolume -Type XDP

>> 

>> # Start the initial transfer

>> Start-NcSnapMirrorInitialTransfer -SourcePath $srcSVM:$srcVolume -DestinationPath $dstSVM:$dstVolume

>> 

>> # Close the connection to clusters

>> Disconnect-NcController

>> }

At line:14 char:37

+ Initialize-NcSnapMirror -SourcePath $srcSVM:$srcVolume -DestinationPa ...

+                                     ~~~~~~~~

Variable reference is not valid. ':' was not followed by a valid variable name character. Consider using ${} to delimit the name.

At line:14 char:73

+ ... rror -SourcePath $srcSVM:$srcVolume -DestinationPath $dstSVM:$dstVolu ...

+                                                          ~~~~~~~~

Variable reference is not valid. ':' was not followed by a valid variable name character. Consider using ${} to delimit the name.

At line:17 char:47

+ Start-NcSnapMirrorInitialTransfer -SourcePath $srcSVM:$srcVolume -Des ...

+                                               ~~~~~~~~

Variable reference is not valid. ':' was not followed by a valid variable name character. Consider using ${} to delimit the name.

At line:17 char:83

+ ... sfer -SourcePath $srcSVM:$srcVolume -DestinationPath $dstSVM:$dstVolu ...

+                                                          ~~~~~~~~

Variable reference is not valid. ':' was not followed by a valid variable name character. Consider using ${} to delimit the name.

    + CategoryInfo          : ParserError: (:) [], ParentContainsErrorRecordException

    + FullyQualifiedErrorId : InvalidVariableReferenceWithDrive

Northman
3,700 Views

 got a round that error by adding the brackets as suggested, but ran into a new problem with wrong initialize-command. Currently testing with the  : 'Invoke-NcSnapMirrorInitialize" command using the same Excel-file. Anyone knows the fastest way to setup scheduled snapmirror transfers after this for all the volumes? I assum e applying a schedule policy with a script to all the volumes?

Northman
3,699 Views

I then ran into a similar problem with the NcConnect command:

 

>> Invoke-NcSnapmirrorInitialize -DestinationCluster $dstClusterIP -DestinationVserver $dstSVM -DestinationVolume $dstVolume -SourceCluster $srcClusterIP -SourceVserver $srcSVM -SourceVolume $srcVolume -Controller “Dst IP”

>> 

>> # Updates must be done manually, or a schedule created and run with other command in ONTAP CLI or here in Poershell

>> }

 

Name                 Address           Vserver              Version

----                 -------           -------              -------

“dst IP»           «Dst IP»                           NetApp Release 9.11.1P8: Fri Apr 07 00:02:50 UTC 2023

«src IP»           «src IP»                           NetApp Release 9.11.1P8: Fri Apr 07 00:02:50 UTC 2023

Invoke-NcSnapmirrorInitialize : Incorrect credentials for “dst-IP”

At line:14 char:1

+ Invoke-NcSnapmirrorInitialize -DestinationCluster $dstClusterIP -Dest ...

+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (“Dst IP”:NcController) [Invoke-NcSnapmirrorInitialize], NaAuthException

    + FullyQualifiedErrorId : ApiException,DataONTAP.C.PowerShell.SDK.Cmdlets.Snapmirror.InvokeNcSnapmirrorInitialize

TzwaynY
3,093 Views

Acatually iam a bit confused by your question.

 

You need to connect to the Destination Cluster:

 

Connect-NcController -Name $DestinationClusterIP -Credentials (Get-Credentials)

After that you have to invoke your desired Snapmirror Relation. For example:

 

$SnapMirror = Get-NcSnapmirror -ZapiCall | Where-Object {$_.Status -eq "uninitilized"}

ForEach($Snapmirror_ in $Snapmirror){

try{

Invoke-NcSnapmirrorInitilize -DestinationVserver $Snapmirror_.DestinationVserver -DestinationVolume $Snapmirror_.DestinationVolume

}catch{

Write-Host $_.Exception.Message

}

}

Thats all you need. If you need any further help, feel free to ask, or if anything is unclear (or maybe I understood it wrong) reach back out to me.

 

best regards

Kai

Northman
3,038 Views

hello Kai, but I am connecting to both the destination and the source. See the post 23. august in the script. Is the error that I only should connect to the destination, perhaps?

TzwaynY
2,943 Views

Hi,

sorry for the late reply. Yes you need to be connected to the destination and nothing else.

Best regards

Kai

Northman
153 Views

Kai,

Started working on this again and no luck after 2 days. I need this to work with a Excel input-file. I am using the module ImportExcel.

 

I could provid emy script here, but would be interested in a simple solution before that, as my script involves some troubleshooting checks also.

Public