Backing up databases using PowerShell cmdlets

Backing up a database includes establishing a connection with the SnapCenter Server, adding resources, adding a policy, creating a backup resource group, and backing up.

Before you begin

About this task

The SnapCenter cmdlet help and the cmdlet reference information contain more information about PowerShell cmdlets.

SnapCenter Software 4.0 Windows Cmdlet Reference Guide

Steps

  1. Initiate a connection session with the SnapCenter Server for a specified user by using the Open-SmConnection cmdlet.
    Example
    Open-smconnection  -SMSbaseurl  https:\\snapctr.demo.netapp.com:8146\
    The username and password prompt is displayed.
  2. Add resources by using the Add-SmResources cmdlet.
    Example
    This example shows how to add a SAP HANA database of SingleContainer type:
    C:\PS> Add-SmResource -HostName '10.232.204.42' -PluginCode 'HANA' -DatabaseName H10 -ResourceType SingleContainer -StorageFootPrint (@{"VolumeName"="HanaData10";"StorageSystem"="vserver_scauto_primary"}) -SID 'H10' -filebackuppath '/tmp/HanaFileLog' -userstorekeys 'HS10' -osdbuser 'h10adm' -filebackupprefix 'H10_'
    Example
    This example shows how to adds a SAP HANA database of MultipleContainers type:
    C:\PS> Add-SmResource -HostName 'scspr0204312001.gdl.englab.netapp.com' -PluginCode 'HANA' -SID 'H11' -TenantDatabaseName 'abc' -TenantType SingleTenant -DatabaseName MDC_SN -ResourceType
      MultipleContainers -userstorekeys 'KEY01' -StorageFootPrint @(@{"storagesystem"="10.232.206.5";"volumename"="dummyvol"}) -filebackuppath '/tmp/HanaFileLog' -userstorekeys 'HS10' -osdbuser 'h10adm' -filebackupprefix 'H10_'
    Note: If you do not specify a value for -filebackuppath and -filebackupprefix, default values are used. The default OSDBUser for Windows is SYSTEM.
    Example
    This example shows how to create a non-data volume resource:
    C:\PS> Add-SmResource -HostName 'SNAPCENTERN42.sccore.test.com' -PluginCode 'hana' -ResourceName NonDataVolume -ResourceType NonDataVolume -StorageFootPrint (@{"VolumeName"="ng_pvol";"StorageSystem"="vserver_scauto_primary"}) -sid 'S10'
  3. Create a backup policy by using the Add-SmPolicy cmdlet.
    Example

    This example creates a backup policy for a Snapshot copy-based backup:

    C:\PS> Add-SmPolicy -PolicyName hana_snapshotbased -PolicyType Backup -PluginPolicyType hana -BackupType SnapShotBasedBackup
    
    Example

    This example creates a backup policy for a File-Based backup:

    C:\PS> Add-SmPolicy -PolicyName hana_Filebased -PolicyType Backup -PluginPolicyType hana -BackupType FileBasedBackup
    
  4. Protect the resource or add a new resource group to SnapCenter by using the Add-SmResourceGroup cmdlet.
    Example

    This example protects a single container resource:

    C:\PS> Add-SmProtectResource -PluginCode HANA  -Policies hana_snapshotbased,hana_Filebased
     -Resources @{"Host"="host.example.com";"UID"="SID"} -Description test -usesnapcenterwithoutfilesystemconsistency
    
    Example

    This example protects a multiple containers resource:

    C:\PS> Add-SmProtectResource -PluginCode HANA  -Policies hana_snapshotbased,hana_Filebased
     -Resources @{"Host"="host.example.com";"UID"="SID\TenantDatabaseName"} -Description test -usesnapcenterwithoutfilesystemconsistency
    
    Example

    This example creates a new resource group with the specified policy and resources:

    C:\PS> Add-SmResourceGroup -ResourceGroupName 'ResourceGroup_with_SingleContainer_MultipleContainers_Resources' -Resources @(@{"Host"="sccorelinux61.sccore.test.com";"Uid"="SID"},@{"Host"="sccorelinux61.sccore.test.com";"Uid"="SID\TenantDatabaseName"})
      -Policies hana_snapshotbased,hana_Filebased  -usesnapcenterwithoutfilesystemconsistency  -plugincode 'HANA'
    
    Example
    This example creates a non-data volume resource group:
    Add-SmResourceGroup -ResourceGroupName 'Mixed_RG_backup_when_Remove_Backup_throguh_BackupName_windows' -Resources @(@{"Host"="SNAPCENTERN42.sccore.test.com";"Uid"="H11";"PluginName"="hana"},@{"Host"="SNAPCENTERN42.sccore.test.com";"Uid"="H31\H31";"PluginName"="hana"},@{"Host"="SNAPCENTERN42.sccore.test.com";"Uid"="NonDataVolume\S10\NonDataVolume";"PluginName"="hana"}) -Policies hanaprimary
  5. Initiate a new backup job by using the New-SmBackup cmdlet.
    Example

    This example shows how to backup a resource group:

    C:\PS> New-SMBackup -ResourceGroupName 'ResourceGroup_with_SingleContainer_MultipleContainers_Resources'  -Policy hana_snapshotbased
    
    Example

    This example backs up a protected resource:

    C:\PS> New-SMBackup -Resources @{"Host"="10.232.204.42";"Uid"="SID\TenantDatabaseName";"PluginName"="hana"} -Policy hana_Filebased
    
  6. Monitor the job status (running, completed, or failed) by using the Get-smJobSummaryReport cmdlet.
    Example
    PS C:\> Get-smJobSummaryReport -JobID 123
    
  7. Monitor the backup job details like backup ID, backup name to perform restore or clone operation by using the Get-SmBackupReport cmdlet.
    Example
    PS C:\> Get-SmBackupReport -JobId 351
    Output:
    BackedUpObjects           : {DB1}
    FailedObjects             : {}
    IsScheduled               : False
    HasMetadata               : False
    SmBackupId                : 269
    SmJobId                   : 2361
    StartDateTime             : 10/4/2016 11:20:45 PM
    EndDateTime               : 10/4/2016 11:21:32 PM
    Duration                  : 00:00:46.2536470
    CreatedDateTime           : 10/4/2016 11:21:09 PM
    Status                    : Completed
    ProtectionGroupName       : Verify_ASUP_Message_windows
    SmProtectionGroupId       : 211
    PolicyName                : test2
    SmPolicyId                : 20
    BackupName                : Verify_ASUP_Message_windows_scc54_10-04-2016_23.20.46.2758
    VerificationStatus        : NotVerified
    VerificationStatuses      : 
    SmJobError                : 
    BackupType                : SCC_BACKUP
    CatalogingStatus          : NotApplicable
    CatalogingStatuses        : 
    ReportDataCreatedDateTime :