SnapCenter 6.0 Cmdlet Reference Guide For Windows ( CA08871-610en )
About PowerShell commands for SnapCenter Plug-ins Package for Windows
This command reference document is a compilation of all the PowerShell help pages for PowerShell cmdlets. It includes the cmdlets for both the SnapCenter Plug-in for Windows and the SnapCenter Plug-in for SQL Server.
The following are common tasks you might perform using PowerShell cmdlets:
-
Create a storage virtual machine (SVM) connection and a credential
-
Back up SQL Server databases
-
Restore and recover SQL Server databases
-
Clone SQL Server database backups
Create a storage system connection and a credential using PowerShell cmdlets
You must create a storage virtual machine (SVM) connection and a credential before using PowerShell cmdlets to perform data protection operations.
-
You should have prepared the PowerShell environment to execute the PowerShell cmdlets.
-
You should have the required permissions in the Infrastructure Admin role to create storage connections.
-
You should ensure that the plug-in installations are not in progress.
Host plug-in installations must not be in progress while adding a storage system connection because the host cache might not be updated and databases status might be displayed in the SnapCenter GUI as "Not available for backup" or "Not on NetApp storage". -
Storage system names should be unique.
SnapCenter does not support multiple storage systems with the same name on different clusters. Each storage system that is supported by SnapCenter should have a unique name and a unique data LIF IP address.
-
Initiate a PowerShell connection session by using the Open-SmConnection cmdlet. This example opens a PowerShell session:
PS C:\> Open-SmStorageConnection
-
Create a new connection to the storage system by using the Add-SmStorageConnection cmdlet.
This example creates a new storage system connection:PS C:\> Add-SmStorageConnection -Storage test_vs1 -Protocol Https -Timeout 60
-
Create a new credential by using the Add-SmCredential cmdlet. This example creates a new credential named FinanceAdmin with Windows credentials:
PS C:> Add-SmCredential -Name FinanceAdmin -AuthMode Windows -Credential sddev\administrator
Back up resources using PowerShell cmdlets
You can use the PowerShell cmdlets to backup SQL Server databases or Windows file systems. This would include backing up a SQL Server database or Windows file system includes establishing a connection with the SnapCenter Server, discovering the SQL Server database instances or Windows file systems, adding a policy, creating a backup resource group, backing up, and verifying the backup.
-
You must have prepared the PowerShell environment to execute the PowerShell cmdlets.
-
You must have added the storage system connection and created a credential.
-
You must have added hosts and discovered resources.
-
Initiate a connection session with the SnapCenter Server for a specified user by using the Open-SmConnection cmdlet.
Open-smconnection -SMSbaseurl https://snapctr.demo.netapp.com:8146
The username and password prompt is displayed.
-
Create a backup policy by using the Add-SmPolicy cmdlet.
This example creates a new backup policy with a SQL backup type of FullBackup:PS C:\> Add-SmPolicy -PolicyName TESTPolicy -PluginPolicyType SCSQL -PolicyType Backup -SqlBackupType FullBackup -Verbose
This example creates a new backup policy with a Windows file system backup type of CrashConsistent:
PS C:\> Add-SmPolicy -PolicyName FileSystemBackupPolicy -PluginPolicyType SCW -PolicyType Backup -ScwBackupType CrashConsistent -Verbose
-
Discover host resources by using the Get-SmResources cmdlet.
This example discovers the resources for the Microsoft SQL plug-in on the specified host:C:\PS>PS C:\> Get-SmResources -HostName vise-f6.sddev.mycompany.com -PluginCode SCSQL
This example discovers the resources for Windows file systems on the specified host:
C:\PS>PS C:\> Get-SmResources -HostName vise2-f6.sddev.mycompany.com -PluginCode SCW
-
Add a new resource group to SnapCenter by using the Add-SmResourceGroup cmdlet.
This example creates a new SQL database backup resource group with the specified policy and resources:PS C:\> Add-SmResourceGroup -ResourceGroupName AccountingResource -Resources @{"Host"="visef6.org.com"; "Type"="SQL Database";"Names"="vise-f6\PayrollDatabase"} -Policies "BackupPolicy"
This example creates a new Windows file system backup resource group with the specified policy and resources:
PS C:\> Add-SmResourceGroup -ResourceGroupName EngineeringResource -PluginCode SCW -Resources @{"Host"="WIN-VOK20IKID5I"; "Type"="Windows Filesystem";"Names"="E:\"} -Policies "EngineeringBackupPolicy
-
Initiate a new Snapshot copy job by using the New-SmBackup cmdlet.
PS C:> New-SmBackup -ResourceGroupName PayrollDataset -Policy FinancePolicy
-
View the status of the backup job by using the Get-SmBackupReport cmdlet.
This example displays a job summary report of all jobs that were run on the specified date:PS C:\> Get-SmJobSummaryReport -Date ?1/27/2016?
Restore and recover resources using PowerShell cmdlets
Restoring and recovering a SQL Server database or Windows file system includes initiating a connection session with the SnapCenter Server, listing the backups and retrieving backup information, and restoring a backup.
You must have prepared the PowerShell environment to execute the PowerShell cmdlets.
-
Initiate a connection session with the SnapCenter Server for a specified user by using the Open-SmConnection cmdlet.
Open-smconnection -SMSbaseurl https://snapctr.demo.netapp.com:8146
-
Retrieve the information about the one or more backups that you want to restore by using the Get-SmBackupand Get-SmBackupReport cmdlets.
This example displays information about all available backups:PS C:\> Get-SmBackup BackupId BackupName BackupTime BackupType 1 Payroll Dataset_vise-f6_08... 8/4/2015 11:02:32 AM Full Backup 2 Payroll Dataset_vise-f6_08... 8/4/2015 11:23:17 AM
This example displays detailed information about the backup Secondary_SCSPR0019366001_01-15-2015_06.49.08:
PS C:\> Get-SmBackupReport -BackupName Secondary_SCSPR0019366001_01-15-2015_06.49.08 BackedUpObjects : {TestDB1, TestDB2, TestDB3, TestDB4...} FailedObjects : {} BackupType : Full Backup IsScheduled : False SmBackupId : 52 SmJobId : 585 StartDateTime : 1/15/2015 6:49:07 AM EndDateTime : 1/15/2015 6:49:21 AM Duration : 00:00:13.8370000 CreatedDateTime : 1/15/2015 6:49:18 AM Status : Completed ProtectionGroupName : Secondary SmProtectionGroupId : 5 PolicyName : Vault SmPolicyId : 18 BackupName : Secondary_SCSPR0019366001_01-15-2015_06.49.08 VerificationStatus : NotVerified
-
Restore data from the backup by using the Restore-SmBackup cmdlet.
C:\PS>PS C:\> Restore-SmBackup -PluginCode SCSQL -AppObjectId 'vise-f6\PayrollDatabase' -BackupName 'NetApp_PayrollDataset_Backup Policy_ vise-f6_NetApp_08-07-2015_08.48.59.6962' -RestoreWhenOnline Name Id StartTime EndTime IsCancellable IsRestartable IsCompleted IsVisible : Restore 'vise-f6\PayrollDatabase' : 199 : 8/7/2015 9:21:36 AM : : False : False : False : False IsScheduled : False PercentageCompleted : 0 Description : Status : Queued Owner : Error : Priority : None Tasks : {} ParentJobID : 0 EventId : 0
Restore-SmBackup -PluginCode SCSQL -AppObjectId 'scspr0270378001\abc' -BackupName 'scspr0270378001_abc_scspr0270378001_07-25-2017_04.51.10.5795' -AlternatePath @{Source='D:\data\abc.mdf';Destination='D:\data\bharathaewf123.mdf'},@{Source='D:\log\bharath_log.ldf';Destination='D:\log\bharathaef_log123.ldf'} -SQLInstanceName 'scspr0273089004' -DatabaseName 'abc123adwqa1231' -ExistingFiles
Clone backups using PowerShell cmdlets
The clone workflow includes planning, performing the clone operation, and monitoring the operation.
You must have prepared the PowerShell environment to execute the PowerShell cmdlets.
-
Initiate a connection session with the SnapCenter Server for a specified user by using the Open-SmConnection cmdlet.
Open-SmConnection -SMSbaseurl https://snapctr.demo.netapp.com:8146
-
List the backups that can be cloned by using the Get-SmBackupor Get-SmResourceGroup cmdlet.
This example displays information about all available backups:C:\PS>PS C:\> Get-SmBackup BackupId BackupName BackupTime BackupType 1 Payroll Dataset_vise-f6_08... 8/4/2015 11:02:32 AM Full Backup 2 Payroll Dataset_vise-f6_08... 8/4/2015 11:23:17 AM
This example displays information about a specified resource group, its resources, and associated policies:
PS C:\> Get-SmResourceGroup -ListResources –ListPolicies Description : CreationTime : 8/4/2015 3:44:05 PM ModificationTime : 8/4/2015 3:44:05 PM EnableEmail : False EmailSMTPServer : EmailFrom : EmailTo : EmailSubject : EnableSysLog : False ProtectionGroupType : Backup EnableAsupOnFailure : False Policies : {FinancePolicy} HostResourceMaping : {} Configuration : SMCoreContracts.SmCloneConfiguration LastBackupStatus : VerificationServer : EmailBody : EmailNotificationPreference : Never VerificationServerInfo : SMCoreContracts.SmVerificationServerInfo SchedulerSQLInstance : CustomText : CustomSnapshotFormat : SearchResources : False ByPassCredential : False IsCustomSnapshot : MaintenanceStatus : Production PluginProtectionGroupTypes : {SMSQL} Name : Payrolldataset Type : Group Id : 1 Host : UserName : Passphrase : Deleted : False Auth : SMCoreContracts.SmAuth IsClone : False CloneLevel : 0 ApplySnapvaultUpdate : False ApplyRetention : False RetentionCount : 0 RetentionDays : 0 ApplySnapMirrorUpdate : False SnapVaultLabel : MirrorVaultUpdateRetryCount : 7 AppPolicies : {} Description : FinancePolicy PreScriptPath : PreScriptArguments : PostScriptPath : PostScriptArguments : ScriptTimeOut : 60000 DateModified : 8/4/2015 3:43:30 PM DateCreated : 8/4/2015 3:43:30 PM Schedule : SMCoreContracts.SmSchedule PolicyType : Backup PluginPolicyType : SMSQL Name : FinancePolicy Type : Id : 1 Host : UserName : Passphrase : Deleted : False Auth : SMCoreContracts.SmAuth IsClone : False CloneLevel : 0 clab-a13-13.sddev.lab.netapp.com DatabaseGUID : SQLInstance : clab-a13-13 DbStatus : AutoClosed DbAccess : eUndefined IsSystemDb : False IsSimpleRecoveryMode : False IsSelectable : True SqlDbFileGroups : {} SqlDbLogFiles : {} AppFileStorageGroups : {} LogDirectory : AgName : Version : VolumeGroupIndex : -1 IsSecondary : False Name : TEST Type : SQL Database Id : clab-a13-13\TEST Host : clab-a13-13.sddev.mycompany.com UserName : Passphrase : Deleted : False Auth : SMCoreContracts.SmAuth IsClone : False
-
Initiate a clone operation from an existing backup by using the New-SmClone cmdlet. This example creates a clone from a specified backup with all logs:
PS C:\> New-SmClone -BackupName payroll_dataset_vise-f3_08-05-2015_15.28.28.9774 -Resources @{"Host"="vise-f3.sddev.mycompany.com"; "Type"="SQL Database";"Names"="vise-f3\SQLExpress\payroll"} -CloneToInstance vise-f3\sqlexpress -AutoAssignMountPoint -Suffix _clonefrombackup -LogRestoreType All -Policy clonefromprimary_ondemand PS C:> New-SmBackup -ResourceGroupName PayrollDataset -Policy FinancePolicy
This example creates a clone to a specified Microsoft SQL Server instance:
PS C:\> New-SmClone -BackupName "BackupDS1_NY-VM-SC-SQL_12-08-2015_09.00.24.8367" -Resources @{"host"="ny-vm-sc-sql";"Type"="SQL Database"; "Names"="ny-vm-sc-sql\AdventureWorks2012_data"} -AppPluginCode SMSQL -CloneToInstance "ny-vm-sc-sql" -Suffix _CLPOSH -AutoAssignMountPoint -AssignMountPointUnderPath "C:\SCMounts"
-
View the status of the clone job by using the Get-SmCloneReport cmdlet. This example displays a clone report for the specified job ID:
PS C:\> Get-SmCloneReport -JobId 186 SmCloneId : 1 SmJobId : 186 StartDateTime : 8/3/2015 2:43:02 PM EndDateTime : 8/3/2015 2:44:08 PM Duration : 00:01:06.6760000 Status : Completed ProtectionGroupName : Draper SmProtectionGroupId : 4 PolicyName : OnDemand_Clone SmPolicyId : 4 BackupPolicyName : OnDemand_Full_Log SmBackupPolicyId : 1 CloneHostName : SCSPR0054212005.mycompany.com CloneHostId : 4 CloneName : Draper clone 08-03-2015_14.43.53 SourceResources : {Don, Betty, Bobby, Sally} ClonedResources : {Don_DRAPER, Betty_DRAPER, Bobby_DRAPER, Sally DRAPER}