Protect new NetApp NFS Exports with Veeam

The capability to protect NFS and SMB Shares on file level was one of the most wanted features of Veeam Availability Suite v10. With prior versions, you only had the option of NDMP Backup to Tape. The NAS Backup feature is designed for a large scale and wide compatibility. In my opinion, there is currently only a small problem with using this new feature: There is no integration like vCenter or VMM available that auto-protects all new shares in Veeam Backup & Replication. To make sure all new NetApp exports are backed up, I have created a PowerShell Function to automatically Protect new NetApp NFS Exports with Veeam.

The PowerShell Function creates a new NetApp Volume on an existing Aggregate, Storage Virtual Machine (SVM) and Ethernet Interface. The root of the new Volume will be exported to the given IP under usage of the given export policy name. if the export policy already exists, the IP will be added as a new rule. On the Veeam Backup & Replication Server, a Backup Repository for Backup Files and the Cache needs to be available. All these pre-requirements are gathered as a Dynamic ValidateSet in a Dynamic Parameter to simplify the input.

Protect new NetApp NFS Exports with Veeam - Dynamic ValidateSet in a Dynamic Parameter

I have adopted the “Dynamic ValidateSet in a Dynamic Parameter” part from an older project: Create VMware vSphere NetApp NFS Volume

Note:
The PowerShell function is not able to fully validate your input against the environment. It might be possible that the Veeam Server is not able to access the chosen Ethernet Interface or the NetApp Aggregate has not enough space for the new Volume.

New-VeeamNetappVolume Example

New-VeeamNetappVolume -NFS -IP 10.0.2.16 -ExportPolicyName veeam -VolName vol_nfs_03 -VolSize 1 -VeeamCacheRepo 'Default Backup Repository' -NetAppAggregate aggr1_data01 -NetAppVserver svm_veeam_nfs -NetAppInterface svm_veeam_nfs_nfs_lif1 -NetAppSnapshotPolicy default
Protect new NetApp NFS Exports with Veeam - New NetApp Volume
New NetApp Volume
Protect new NetApp NFS Exports with Veeam - New Veeam NAS Server
New Veeam NAS Server
Protect new NetApp NFS Exports with Veeam - New Veeam NAS Backup Job
New Veeam NAS Backup Job

Demo of the full process

This video will show how the New-VeeamNetappVolume PowerShell Function will automatically Protect new NetApp NFS Exports with Veeam. Once with and once without a new Veeam Backup Job.

PowerShell Function

The New-VeeamNetappVolume Function is currently the only exported Function of the module.

ParameterSetDescription
[Switch] NFSNFSNFS Export will be created
[Switch] SMBSMBSMB Share will be created
[Switch] CreateBackupJobBackup Job will be created
[IP Address] IPNFSClient IP for the NFS Export (Backup Proxy)
[String] ExportPolicyNameNFSName of the Export Policy
[String] VolNameName of the new Volume
[Integer] VolSizeSize of the new Volume in GB
[String] VeeamBackupRepoThe Veeam Backup Repo Name
[String] VeeamCacheRepoThe Veeam Cache Repo Name
[String] NetAppAggregateNameName of the Aggregate where the Volume is created
[String] NetAppVserverNameName of the SVM where the Volume is created
[String] NetAppInterfaceNameName of the Interface that should be used for the mount
[String] NetAppSnapshotPolicyName of the Snapshot Policy for the Volume
function New-VeeamNetappVolume {
    <#
    .DESCRIPTION
    Creates a new a NetApp Volume and adds it to Veeam Configuration as a NAS Backup Job.

    .NOTES
    File Name  : New-VeeamNetappVolume.psm1
    Author     : Markus Kraus
    Version    : 0.3
    State      : Dev

    .LINK
    https://mycloudrevolution.com/

    .EXAMPLE
    New-VeeamNetappVolume -NFS -IP 10.0.2.16 -ExportPolicyName veeam -VolName vol_nfs_01 -VolSize 1 -VeeamCacheRepo 'Default Backup Repository' -NetAppAggregate aggr1_data01 -NetAppVserver svm_veeam_nfs -NetAppInterface svm_veeam_nfs_nfs_lif1 -NetAppSnapshotPolicy default

    .EXAMPLE
    New-VeeamNetappVolume -NFS -IP 10.0.2.16 -ExportPolicyName veeam -VolName vol_nfs_01 -VolSize 1 -CreateBackupJob -VeeamBackupRepo 'Default Backup Repository' -VeeamCacheRepo 'Default Backup Repository' -NetAppAggregate aggr1_data01 -NetAppVserver svm_veeam_nfs -NetAppInterface svm_veeam_nfs_nfs_lif1 -NetAppSnapshotPolicy default

    .PARAMETER CreateBackupJob
    Create a Backup Job fot the New NAS Server

    .PARAMETER NFS
    NFS Volume

    .PARAMETER SMB
    SMB Volume

    .PARAMETER IP
    IP for the NFS Export

    .PARAMETER VolName
    Name of the new Volume

    .PARAMETER VolSize
    Size of the new Volume in GB

    .PARAMETER VeeamBackupRepo
    The Veeam Backup Repo Name

    .PARAMETER NetAppAggregateName
     Name of the Aggregate where the Volume is created

    .PARAMETER NetAppVserverName
    Name of the SVM where the Volume is created

    .PARAMETER NetAppInterfaceName
    Name of the Interface that should be used for the mount

    .PARAMETER VeeamCacheRepo
    The Veeam Cache Repo Name

    #>

    [CmdletBinding()]
    Param (
        [Parameter(Mandatory=$False, ValueFromPipeline=$False, HelpMessage="Create Backup Job")]
        [ValidateNotNullorEmpty()]
            [Switch]$CreateBackupJob,
        [Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="NFS Volume", ParameterSetName="NFS")]
        [ValidateNotNullorEmpty()]
            [Switch]$NFS,
        [Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="SMB Volume", ParameterSetName="SMB")]
        [ValidateNotNullorEmpty()]
            [Switch]$SMB,
        [Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="IP for the NFS Export", ParameterSetName="NFS")]
        [ValidateNotNullorEmpty()]
            [ipaddress]$IP,
        [Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Name of the Export Policy", ParameterSetName="NFS")]
        [ValidateNotNullorEmpty()]
            [String]$ExportPolicyName,
        [Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Name of the new Volume")]
        [ValidateNotNullorEmpty()]
            [String]$VolName,
        [Parameter(Mandatory=$True, ValueFromPipeline=$False, HelpMessage="Size of the new Volume in GB")]
        [ValidateNotNullorEmpty()]
            [int]$VolSize
    )

    DynamicParam {
        # Verification
        Test-NetappConnection
        Test-VeeamConnection
        
        # Veeam Cache Repo
        $VeeamCacheRepoName = 'VeeamCacheRepo'
        $VeeamCacheRepoAttributeProperty = @{
            Mandatory = $true;
            ValueFromPipeline = $False;
            HelpMessage = 'The Veeam Cache Repo Name'
        }
        $VeeamCacheRepoAttribute = New-Object System.Management.Automation.ParameterAttribute -Property $VeeamCacheRepoAttributeProperty

        $VeeamCacheRepoValidateSet = Get-VBRBackupRepository | Select-Object -ExpandProperty Name
        $VeeamCacheRepoValidateSetAttribute = New-Object System.Management.Automation.ValidateSetAttribute($VeeamCacheRepoValidateSet)

        $VeeamCacheRepoAttributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute]
        $VeeamCacheRepoAttributeCollection.Add($VeeamCacheRepoAttribute)
        $VeeamCacheRepoAttributeCollection.Add($VeeamCacheRepoValidateSetAttribute)

        $VeeamCacheRepoRuntimeParameter = New-Object System.Management.Automation.RuntimeDefinedParameter($VeeamCacheRepoName, [string], $VeeamCacheRepoAttributeCollection)

        # Veeam Backup Repo
        $VeeamBackupRepoName = 'VeeamBackupRepo'
        $VeeamBackupRepoAttributeProperty = @{
            Mandatory = $false;
            ValueFromPipeline = $False;
            HelpMessage = 'The Veeam Backup Repo Name'
        }
        $VeeamBackupRepoAttribute = New-Object System.Management.Automation.ParameterAttribute -Property $VeeamBackupRepoAttributeProperty

        $VeeamBackupRepoValidateSet = Get-VBRBackupRepository | Select-Object -ExpandProperty Name
        $VeeamBackupRepoValidateSetAttribute = New-Object System.Management.Automation.ValidateSetAttribute($VeeamBackupRepoValidateSet)

        $VeeamBackupRepoAttributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute]
        $VeeamBackupRepoAttributeCollection.Add($VeeamBackupRepoAttribute)
        $VeeamBackupRepoAttributeCollection.Add($VeeamBackupRepoValidateSetAttribute)

        $VeeamBackupRepoRuntimeParameter = New-Object System.Management.Automation.RuntimeDefinedParameter($VeeamBackupRepoName, [string], $VeeamBackupRepoAttributeCollection)

        # NetApp vServer parameter
        $NetAppVserverName = 'NetAppVserver'
        $NetAppVserverAttributeProperty = @{
            Mandatory = $true;
            ValueFromPipeline = $False;
            HelpMessage = 'The NetApp Vserver Name'
        }
        $NetAppVserverAttribute = New-Object System.Management.Automation.ParameterAttribute -Property $NetAppVserverAttributeProperty

        $NetAppVserverValidateSet = (Get-NcVserver).where({$_.VserverType -eq "data"}) | Select-Object -ExpandProperty Vserver
        $NetAppVserverValidateSetAttribute = New-Object System.Management.Automation.ValidateSetAttribute($NetAppVserverValidateSet)

        $NetAppVserverAttributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute]
        $NetAppVserverAttributeCollection.Add($NetAppVserverAttribute)
        $NetAppVserverAttributeCollection.Add($NetAppVserverValidateSetAttribute)

        $NetAppVserverRuntimeParameter = New-Object System.Management.Automation.RuntimeDefinedParameter($NetAppVserverName, [string], $NetAppVserverAttributeCollection)

        # NetApp Aggregate parameter
        $NetAppAggregateName = 'NetAppAggregate'
        $NetAppAggregateAttributeProperty = @{
            Mandatory = $true;
            ValueFromPipeline = $False;
            HelpMessage = 'The NetApp Aggregate Name'
        }
        $NetAppAggregateAttribute = New-Object System.Management.Automation.ParameterAttribute -Property $NetAppAggregateAttributeProperty

        $NetAppAggregateValidateSet = Get-NcAggr | Select-Object -ExpandProperty Name
        $NetAppAggregateValidateSetAttribute = New-Object System.Management.Automation.ValidateSetAttribute($NetAppAggregateValidateSet)

        $NetAppAggregateAttributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute]
        $NetAppAggregateAttributeCollection.Add($NetAppAggregateAttribute)
        $NetAppAggregateAttributeCollection.Add($NetAppAggregateValidateSetAttribute)

        $NetAppAggregateRuntimeParameter = New-Object System.Management.Automation.RuntimeDefinedParameter($NetAppAggregateName, [string], $NetAppAggregateAttributeCollection)

        # NetApp Interface parameter
        $NetAppInterfaceName = 'NetAppInterface'
        $NetAppInterfaceAttributeProperty = @{
            Mandatory = $true;
            ValueFromPipeline = $False;
            HelpMessage = 'The NetApp Interface Name'
        }
        $NetAppInterfaceAttribute = New-Object System.Management.Automation.ParameterAttribute -Property $NetAppInterfaceAttributeProperty

        $NetAppInterfaceValidateSet = (Get-NcNetInterface).where({$_.DataProtocols -match "nfs|cifs"}) | Select-Object -ExpandProperty InterfaceName
        $NetAppInterfaceValidateSetAttribute = New-Object System.Management.Automation.ValidateSetAttribute($NetAppInterfaceValidateSet)

        $NetAppInterfaceAttributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute]
        $NetAppInterfaceAttributeCollection.Add($NetAppInterfaceAttribute)
        $NetAppInterfaceAttributeCollection.Add($NetAppInterfaceValidateSetAttribute)

        $NetAppInterfaceRuntimeParameter = New-Object System.Management.Automation.RuntimeDefinedParameter($NetAppInterfaceName, [string], $NetAppInterfaceAttributeCollection)

        # NetApp SnapShot Policy parameter
        $NetAppSnapshotPolicyName = 'NetAppSnapshotPolicy'
        $NetAppSnapshotPolicyAttributeProperty = @{
            Mandatory = $true;
            ValueFromPipeline = $False;
            HelpMessage = 'The NetApp Aggregate Name'
        }
        $NetAppSnapshotPolicyAttribute = New-Object System.Management.Automation.ParameterAttribute -Property $NetAppSnapshotPolicyAttributeProperty

        $NetAppSnapshotPolicyValidateSet = (Get-NcSnapshotPolicy).where({$_.Enabled -eq "True"}) | Select-Object -ExpandProperty Policy
        $NetAppSnapshotPolicyValidateSetAttribute = New-Object System.Management.Automation.ValidateSetAttribute($NetAppSnapshotPolicyValidateSet)

        $NetAppSnapshotPolicyAttributeCollection = New-Object System.Collections.ObjectModel.Collection[System.Attribute]
        $NetAppSnapshotPolicyAttributeCollection.Add($NetAppSnapshotPolicyAttribute)
        $NetAppSnapshotPolicyAttributeCollection.Add($NetAppSnapshotPolicyValidateSetAttribute)

        $NetAppSnapshotPolicyRuntimeParameter = New-Object System.Management.Automation.RuntimeDefinedParameter($NetAppSnapshotPolicyName, [string], $NetAppSnapshotPolicyAttributeCollection)

        # Create and return parameter dictionary
        $RuntimeParameterDictionary = New-Object System.Management.Automation.RuntimeDefinedParameterDictionary
        $RuntimeParameterDictionary.Add($VeeamCacheRepoName, $VeeamCacheRepoRuntimeParameter)
        if ($CreateBackupJob){
                $RuntimeParameterDictionary.Add($VeeamBackupRepoName, $VeeamBackupRepoRuntimeParameter)
        }
        $RuntimeParameterDictionary.Add($NetAppAggregateName, $NetAppAggregateRuntimeParameter)
        $RuntimeParameterDictionary.Add($NetAppVserverName, $NetAppVserverRuntimeParameter)
        $RuntimeParameterDictionary.Add($NetAppInterfaceName, $NetAppInterfaceRuntimeParameter)
        $RuntimeParameterDictionary.Add($NetAppSnapshotPolicyName, $NetAppSnapshotPolicyRuntimeParameter)

        $RuntimeParameterDictionary
    }

    Begin {

        

        # Assign DynamicParams to actual variables
        $VeeamCacheRepoName = $PsBoundParameters[$VeeamCacheRepoName]
        if ($VeeamBackupRepoName){
            $VeeamBackupRepoName = $PsBoundParameters[$VeeamBackupRepoName]
        }
        $NetAppAggregateName = $PsBoundParameters[$NetAppAggregateName]
        $NetAppVserverName = $PsBoundParameters[$NetAppVserverName]
        $NetAppInterfaceName = $PsBoundParameters[$NetAppInterfaceName]
        $NetAppSnapshotPolicyName = $PsBoundParameters[$NetAppSnapshotPolicyName]

        # Get real objects from parameters
        try {
            $VeeamCacheRepo = Get-VBRBackupRepository -Name $VeeamCacheRepoName
        }catch{ Throw "Failed to get Veeam Cache Repo" }

        if ($VeeamBackupRepoName){
            try {
                $VeeamBackupRepo = Get-VBRBackupRepository -Name $VeeamBackupRepoName
            }catch{ Throw "Failed to get Veeam Backup Repo" }
        }

        try {
            $NetAppAggr = Get-NcAggr -Name $NetAppAggregateName
        }catch{ Throw "Failed to get NetApp Aggr" }

        try {
            $NetAppVserver = Get-NcVserver -Name $NetAppVserverName
        }catch{ Throw "Failed to get NetApp vServer (SVM)" }

        try {
            $NetAppInterface = Get-NcNetInterface -Name $NetAppInterfaceName
        }catch{ Throw "Failed to get NetApp Interface)" }

        try {
            $NetAppSnapshotPolicy = Get-NcSnapshotPolicy -Name $NetAppSnapshotPolicyName
        }catch{ Throw "Failed to get NetApp Snapshot Policy)" }

        if ($DebugPreference -eq "Inquire") {
                "NetApp Aggregate:"
                $NetAppAggr | Format-Table -Autosize
                "NetApp Vserver (SVM):"
                $NetAppVserver | Format-Table -Autosize
                "NetApp Interface:"
                $NetAppInterface | Format-Table -Autosize
                "NetApp Snapshot Policy:"
                $NetAppSnapshotPolicy | Format-Table -Autosize

        }

        $VolSizeByte = $VolSize * 130023424

    }

    Process {

        if ($NFS) {

            $ClientMatch = $IP

            if(!($NetAppExportPolicy = Get-NcExportPolicy -Name $ExportPolicyName -VserverContext $NetAppVserver )){
                "Create new NetApp Export Policy '$($ExportPolicyName)' on SVM '$($NetAppVserver.Name)' ..."
                $NetAppExportPolicy = New-NcExportPolicy -Name $ExportPolicyName -VserverContext $NetAppVserver
                $NetAppExportRule = New-NcExportRule -VserverContext $NetAppVserver  -Policy $NetAppExportPolicy.PolicyName -ClientMatch $ClientMatch `
                -Protocol NFS -Index 1 -SuperUserSecurityFlavor any -ReadOnlySecurityFlavor any -ReadWriteSecurityFlavor any
            }else{
                "NetApp Export Policy '$($ExportPolicyName)' on SVM '$($NetAppVserver.Name)' aleady exists, add IP"
                $NetAppExportRule = New-NcExportRule -VserverContext $NetAppVserver  -Policy $NetAppExportPolicy.PolicyName -ClientMatch $ClientMatch `
                -Protocol NFS -Index 1 -SuperUserSecurityFlavor any -ReadOnlySecurityFlavor any -ReadWriteSecurityFlavor any

                }

            "Create new NetApp Volume '$VolName' on Aggregate '$($NetAppAggr.AggregateName)' ..."
            $NetAppVolume = New-NcVol -VserverContext $NetAppVserver -Name $VolName -Aggregate $NetAppAggr.AggregateName -JunctionPath $("/" + $VolName) `
            -ExportPolicy $ExportPolicyName -Size $VolSizeByte -SnapshotReserve 20 -SnapshotPolicy $NetAppSnapshotPolicy.Policy

            "Set Advanced Options for NetApp Volume '$VolName' ..."
            $NetAppVolume | Set-NcVolOption -Key fractional_reserve -Value 0
            $NetAppVolume | Set-NcVolOption -Key guarantee -Value none

            "Add New Veeam NAS Server '$($NetAppInterface.Address):/$($VolName)'"
            $VBRNAServer = Add-VBRNASNFSServer -Path "$($NetAppInterface.Address):/$($VolName)" -CacheRepository $VeeamCacheRepo

        }
        elseif ($SMB) {
            "Not Implemented. Sorry..."
        }
        else { Throw "No Volume Type choosen!"}

        if ($CreateBackupJob) {
            if ($NFS) {
                $Object = New-VBRNASBackupJobObject -Server $VBRNAServer -Path $VBRNAServer.Path
            }
            elseif ($SMB) {
                "Not Implemented. Sorry..."
            }

            "Add Veeam Backup Job for NetApp Volume '$VolName' ..."
            $VBRNAServerBackupJob = Add-VBRNASBackupJob -BackupObject $Object -ShortTermBackupRepository $VeeamBackupRepo
        }

    }

}

Main parts of the Function:

  • 81 – 206 Dynamic ValidateSet in Dynamic Parameter
  • 212 – 247 Get real Objects from Input Parameters
  • 269 – 289 Create NetApp Volume and NFS Export
  • 291 – 292 Add Veeam NAS Server
  • 308 – 309 Create optional Veeam Backup Job

Future of the Module and the Function

As my time allows, I will try to add some additional features to the New-VeeamNetappVolume Function: SMB Support, VSS or SnapShot processing, Archive Tier and so on. But also a new Function to add existing NetApp Volumes as Veeam NAS Server (SMB and NFS) is on the To-Do List. In case you have an additional request, feel free to create a new Github issue.

Currently, I am the only contributor to this project but I would be happy if other Veeam and NetApp enthusiasts will join this project. I am pretty sure all contributors can benefit from this project: Dev experience, learn from others, remote team organization, product know-how. Feel free to contact me via any channel if you are interested.

Leave a Reply