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
- Open the Azure Portal and navigate to the snapshot container and select a snapshot.

- 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.
- Download Snapshot
- Paste the SAS URL into a web browser; the snapshot download will start automatically.
- Copy the snapshot file into this folder
- Rename the snapshot file to: snapshot.br

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.

3. Install and Mount Snapshot Using OSFMount
- Download OSFMount from https://www.osforensics.com/tools/mount-disk-images.html.

- Run the installer and follow the prompts to install OSFMount.

- Launch OSFMount.
- Click Mount New.

- Select the downloaded snapshot file.

- If multiple partitions appear, select the one containing your data.
- Assign a drive letter (e.g., E:).
- Check Read-only drive to avoid modifying the snapshot.


- Click OK to mount the image.
- Open File Explorer to verify the new drive is mounted successfully.


4. Restore the Entire Snapshot Script Configuration
- Open PowerShell as Administrator.
- Save the below script as Recover_Snapshot.ps1.
- 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\npbuild25vm" # 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}


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