Skip to content
English
  • There are no suggestions because the search field is empty.

How to Restore a Snapshot (Full Snapshot Recovery)?

This article explains how to restore an entire Azure snapshot to a local directory using OSFMount and PowerShell.  This process copies all files and folders from the mounted snapshot drive (e.g., E:) to a chosen destination folder (e.g., C:\RecoveredSnapshot).

1. Prerequisites

  • You must have access to the Azure snapshot resource.
  • OSFMount installed on your machine.
  • Administrator privileges to run PowerShell scripts.

2. Download Snapshot from Azure 

  1.  Open the Azure Portal and navigate to the snapshot container and select a snapshot. 
    Snapshot-1
  2. Click Generate SAS on the top menu.
    - Set the expiry time as needed (default: 3600 seconds / 1 hour).
    - Click Generate SAS token and URL.
    - Copy the generated SAS URL.
    Snapshot-2
  3.  Download Snapshot 
     - Paste the SAS URL into a web browser; the snapshot download will start automatically.
    Snapshot-3
              - Create a folder: C:\TestSnap
              - Copy the snapshot file into this folder
              - Rename the snapshot file to: snapshot.br
                Snapshot-4

           4.  Decompress Snapshot 

           - Download Brotli from: https://github.com/google/brotli/releases
           - Use: Brotli-x64-windows-static.zip
           - Extract and place brotli.exe in C:\Brotli
           - Open Command Prompt and Run: C:\Brotli\brotli.exe -d snapshot.br
           - Snapshot file is decompressed successfully.
             Snapshot-5

3. Install and Mount Snapshot Using OSFMount 

  1. Download OSFMount from https://www.osforensics.com/tools/mount-disk-images.html.
    OSF-Mount-1
  2. Run the installer and follow the prompts to install OSFMount.
    OSF-Mount-2
  3. Launch OSFMount.
  4. Click Mount New.
    OSF-Mount-3
  5. Select the downloaded snapshot file.
    OSF-Mount-4
  6. If multiple partitions appear, select the one containing your data.
  7. Assign a drive letter (e.g., E:).
  8. Check Read-only drive to avoid modifying the snapshot.
    OSF-Mount-5
    OSF-Mount-6


  9. Click OK to mount the image.
  10. Open File Explorer to verify the new drive is mounted successfully.
    OSF-Mount-7
    Snapshot_Full_Restore - 1

4. Restore the Entire Snapshot Script Configuration

  1. Open PowerShell as Administrator.
  2. Save the below script as Recover_Snapshot.ps1.
  3. Update the configuration variables inside the script:
  • $MountedDrive → specify the OSFMount drive letter (for example, E:)
  • $DestinationDir → specify the folder where the recovered snapshot will be copied (for example, C:\RecoveredSnapshot)
  • $SourceDir → specify the folder path inside the mounted snapshot to restore (for example, "$MountedDrive\FCGContainer\testalias")

       4.   Run the script:
                .\Recover_Snapshot.ps1

       5.   Upon successful execution, all files and folders from the mounted snapshot will be  restored to the destination directory you configured (for example, C:\RecoveredSnapshot).

5 .PowerShell Script – Recover Full Snapshot

# ==============================
# Restore Entire Snapshot 
# ==============================
# --- Configuration ---
$MountedDrive   = "E:"                                   # OSFMount drive letter (mounted snapshot)
$SourceDir      = "$MountedDrive\FCGContainer\npprodtest22"  # Specific folder inside the snapshot to restore
$DestinationDir = "C:\RecoveredSnapshot"                  # Local recovery destination

Write-Host "`n=== Snapshot Restoration Process ===" -ForegroundColor Cyan
Write-Host "Mounted Drive   : $MountedDrive"
Write-Host "Source Folder   : $SourceDir"
Write-Host "Destination Dir : $DestinationDir"
Write-Host "----------------------------------------"

# --- Validate Source Folder ---
if (!(Test-Path $SourceDir)) {
    Write-Host "Source folder '$SourceDir' not found in snapshot. Please verify the path." -ForegroundColor Red
    exit
}

# --- Ensure destination folder exists ---
if (!(Test-Path $DestinationDir)) {
    try {
        New-Item -Path $DestinationDir -ItemType Directory -ErrorAction Stop | Out-Null
        Write-Host "Created destination folder: $DestinationDir" -ForegroundColor Yellow
    } catch {
        Write-Host "Error creating destination folder: $($_.Exception.Message)" -ForegroundColor Red
        exit
    }
}

# --- Start Snapshot Restoration ---
Write-Host "`nRestoring snapshot from $SourceDir to $DestinationDir ..." -ForegroundColor Cyan

try {
    $robocopyArgs = @(
        ('"' + $SourceDir + '"'),
        ('"' + $DestinationDir + '"'),
        '/E',          # Copy all subdirectories including empty ones
        '/COPYALL',    # Preserve all attributes, timestamps, and permissions
        '/R:2',        # Retry twice on failure
        '/W:5',        # Wait 5 seconds between retries
        '/NP',         # No progress display
        '/NFL',        # No file list
        '/NDL'         # No directory list
    )

    # Execute robocopy
    $result = Start-Process -FilePath "robocopy.exe" -ArgumentList $robocopyArgs -Wait -NoNewWindow -PassThru

    # --- Evaluate Exit Code ---
    switch ($result.ExitCode) {
        {$_ -le 3} {
            Write-Host "`nSnapshot restoration completed successfully." -ForegroundColor Green
        }
        default {
            Write-Host "`nRestoration completed with issues. Exit code: $($result.ExitCode)" -ForegroundColor Yellow
            Write-Host "Snapshot restoration incomplete — please review the robocopy output for details." -ForegroundColor Yellow
        }
    }
}
catch {
    Write-Host "Snapshot restoration failed: $($_.Exception.Message)" -ForegroundColor Red
}

          Snapshot_Full_Restore - 2

           Snapshot_Full_Restore - 3

6. Note:

  • To avoid PowerShell script execution restrictions, you may need to set the execution policy temporarily:

                      Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

  • Always mount the snapshot as read-only to avoid accidental changes.
  • robocopy is used for robust and recursive folder copying preserving all metadata.
  • If you encounter any permission issues, run PowerShell as Administrator