Azure

File Share Snapshot automation – Creation

Introduction

The aim of this doc is to explain the method to take automated on-demand snapshots for Azure File Share.

Snapshot for Azure File Share is now in Normal Availability. Beforehand, Azure File Share didn’t have any backup possibility. In case of the File Share getting deleted, there was no mechanism to get well the File Share and the info was misplaced. The File Share Snapshot helps organizations take on-demand snapshot backups of the prevailing File Share for restoring it later as and when required. This doc describes automating this course of.

Pre-requisites

  • Subscription contributor
  • Implementation Steps

Step 1. Seek for Automation Account within the Useful resource Blade and open the Automation Account Service.

Step 2. Click on on + Create to create a brand new Automation Account.

Step 3. Fill within the beneath particulars and click on on Subsequent.

Details

Step 4. Choose the System Assigned checkbox which can assign a System-assigned Managed Identification to this Automation account. Click on on Subsequent.

System Assigned

Step 5. Choose Personal Entry which can allow us to create a Personal Endpoint to this NFS Storage.

Private Access

Step 6. Present the Tags and click on Assessment + Create to validate and create the Automation Account.

Step 7. As soon as the useful resource has been created, go to the useful resource, click on on Runbooks à + Create a Runbook. This runbook is for creating new snapshots.

Create a Runbook

Step 8. Present the Runbook Identify, Kind, Model, and Description, and click on on Assessment + Create to create the Runbook.

Runbook Name

Step 9. It will create the Runbook and open the playground to avoid wasting our code. Within the playground, save the beneath code.

Join-AzAccount -Identification

$StorageAccounts = Get-AzStorageAccount

Write-Output $StorageAccounts

foreach ($sa in $StorageAccounts) {

    $shares = $null

    Write-Host "On the lookout for NFS shares in Storage Account: $($sa.StorageAccountName)"

    $shares = Get-AzRmStorageShare -StorageAccountName $sa.StorageAccountName -ResourceGroupName $sa.ResourceGroupName -ErrorAction SilentlyContinue | ?{ $_.EnabledProtocols -eq "NFS" }

    foreach ($nfsshare in $shares) {

        Write-Host "*** Discovered NFS Share: $($nfsshare.Identify)"

        Write-Host "Creating Snapshot...`n"

        New-AzRmStorageShare -StorageAccountName $sa.StorageAccountName -ResourceGroupName $sa.ResourceGroupName -Identify $nfsshare.Identify -Snapshot -ErrorAction Proceed

    }

    if ($shares -ne $null) {
        Get-AzRmStorageShare -StorageAccountName $sa.StorageAccountName -ResourceGroupName $sa.ResourceGroupName -IncludeSnapshot | ?{ $_.EnabledProtocols -eq "NFS" -and $_.SnapshotTime -ne $null } | Kind-Object SnapshotTime -Descending
    }
}

Step 10. Click on on Schedule click on on + Add a schedule.

 Add a schedule

Step 11. Click on on Schedule as proven within the snapshot beneath.

 Schedule

Step 12. Click on on + Add a Schedule.

 Schedule  runbook

Step 13. Present the schedule for the Automation account to execute the Runbook and click on on Create to create a schedule.

 New Schedule

 Weekly Schedule

Know extra about our firm at Skrots. Know extra about our companies at Skrots Providers, Additionally checkout all different blogs at Weblog at Skrots

Show More

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button