Home / Azure

AzureHow-toBeginner

Restore deleted files and shares in Azure Files: snapshots, soft delete and Azure Backup

A user deleted a folder, or someone deleted the whole Azure Files share. Pick the right recovery source and get the data back with the CLI, Windows or Azure Backup.

Deepak Bhardwaj7 min read

Applies toAzure Files classic SMB shares (Microsoft.Storage), Azure CLI, Azure Backup for Azure Files

Someone deleted a file, overwrote a spreadsheet or removed an entire share. The right recovery depends on what was lost:

What happened Recover from Section
One file or folder deleted or overwritten Share snapshot Restore from a snapshot
Many files deleted or encrypted Azure Backup, or copy from a snapshot Restore with Azure Backup
Whole share deleted Share soft delete Undelete a share
Share deleted, soft delete expired or off Vaulted Azure Backup, if you had it Restore with Azure Backup
Storage account deleted Storage account recovery Not covered here

Share soft delete works at share level only. It does not bring back individual files, so snapshots or backup must exist before the mistake.

Stop further damage

  1. Ask users to stop writing to the affected folder.
  2. Pause any sync or clean-up job that touches it. With Azure File Sync, a deletion on one server spreads to the others.
  3. Note the time of the deletion in UTC. You need a recovery point from before it.

Set the variables

RG=rg-files
SA=stfilesprod01
SHARE=finance
KEY=$(az storage account keys list -g $RG -n $SA --query "[0].value" -o tsv)

If shared key access is disabled on the account, use --auth-mode login with --backup-intent on the az storage file commands, and a data role such as Storage File Data Privileged Contributor. Support for login varies by command and CLI version, so check --help.

Protect the key. It gives full access to the account, so clear it with unset KEY when you finish.

Restore from a snapshot

List the snapshots

az storage share-rm list -g $RG --storage-account $SA --include-snapshot \
  --query "[?name=='$SHARE' && snapshotTime!=null].snapshotTime" -o tsv

Choose the latest timestamp before the deletion and keep it exactly as shown. The snapshot value is part of the address, so it must match:

SNAP="2026-11-24T22:00:07.0000000Z"

Browse it and find the file

az storage file list --account-name $SA --account-key "$KEY" \
  --share-name $SHARE --path "reports/2026" --snapshot "$SNAP" \
  --query "[].{name:name, type:type}" -o table

Copy one file back

Restore beside the original first, so you don't overwrite newer work:

az storage file copy start \
  --source-account-name $SA --source-account-key "$KEY" \
  --source-share $SHARE --source-path "reports/2026/budget.xlsx" \
  --file-snapshot "$SNAP" \
  --account-name $SA --account-key "$KEY" \
  --destination-share $SHARE --destination-path "reports/2026/budget-restored.xlsx"

The copy is asynchronous. Check it:

az storage file show --account-name $SA --account-key "$KEY" \
  --share-name $SHARE --path "reports/2026/budget-restored.xlsx" \
  --query "properties.copy.{status:status, progress:progress}" -o table

The destination's parent folder must exist. If the folder was deleted too, create it with az storage directory create, one level at a time.

Copy a folder back from Windows

On a client with the share mounted, snapshots appear under Properties > Previous Versions. Use Open and copy files out.

Warning

The Restore button in Previous Versions overwrites the current contents of the selected folder with the old version. Use Open and copy what you need instead.

For larger folders, the snapshot is also available through an @GMT path in UTC. robocopy can copy it with permissions. Run it as an account with enough rights, for example one with full control through your share's admin setup:

$snap = '\\stfilesprod01.file.core.windows.net\finance\@GMT-2026.11.24-22.00.07\reports\2026'
$dest = '\\stfilesprod01.file.core.windows.net\finance\_restore\reports\2026'

robocopy $snap $dest /E /COPY:DATS /DCOPY:DAT /R:2 /W:5 /LOG:C:\Temp\restore.log

Don't use /MIR or /PURGE for a restore. They delete destination files that aren't in the snapshot.

Undelete a share

Soft delete keeps deleted shares for the configured number of days. Find the share and its version:

az storage share-rm list -g $RG --storage-account $SA --include-deleted \
  --query "[?deleted].{name:name, version:version, deletedTime:deletedTime, daysLeft:remainingRetentionDays}" -o table

Restore it:

az storage share-rm restore -g $RG --storage-account $SA \
  -n finance --deleted-version 01D64EB9886F00C4

If someone has already created a new share with the same name, restore under another name and move the data:

az storage share-rm restore -g $RG --storage-account $SA \
  -n finance --deleted-version 01D64EB9886F00C4 --restored-name finance-restored

The share's contents and snapshots come back as they were before the deletion. Remount a test client and check permissions before telling users. If the list is empty, soft delete was off at the time or the period has passed.

Tip

If the same name was deleted more than once, you will see several versions. Compare deletedTime before choosing.

Restore with Azure Backup

Use backup when many files are affected or no suitable manual snapshot exists. Find the recovery points first:

VAULT=rsv-files
VRG=rg-backup

az backup item list -g $VRG -v $VAULT \
  --backup-management-type AzureStorage --workload-type AzureFileShare \
  --query "[].{item:name, share:properties.friendlyName, container:properties.containerName}" -o table

az backup recoverypoint list -g $VRG --vault-name $VAULT \
  --container-name $SA --item-name $SHARE \
  --backup-management-type azurestorage --workload-type azurefileshare -o table

If the friendly names are ambiguous, use the full item and container names from the vault. Use a recovery point's Name as --rp-name.

Restore selected folders

az backup restore restore-azurefiles -g $VRG --vault-name $VAULT \
  --container-name $SA --item-name $SHARE --rp-name <recovery-point-name> \
  --resolve-conflict Skip --restore-mode OriginalLocation \
  --source-file-type Directory --source-file-path "reports/2026"

Skip leaves existing files alone. Overwrite replaces them.

Restore the whole share to another share

After ransomware or bulk corruption, restore to a separate share and validate it:

az storage share-rm create -g $RG --storage-account $SA -n finance-recovery --quota 1024

az backup restore restore-azurefileshare -g $VRG --vault-name $VAULT \
  --container-name $SA --item-name $SHARE --rp-name <recovery-point-name> \
  --resolve-conflict Overwrite --restore-mode AlternateLocation \
  --target-storage-account $SA --target-file-share finance-recovery \
  --target-folder ""

Set the quota to fit the restored data. If the target account is in a different resource group from the source, add --target-rg-name. Track the job:

az backup job list -g $VRG -v $VAULT --status InProgress -o table

Caution

Restoring to OriginalLocation with Overwrite replaces good files changed after the recovery point. Take a manual snapshot first so you can undo it.

Common problems

Symptom Cause Fix
403 from az storage file Storage firewall, or shared key disabled Run from an allowed network, or use --auth-mode login --backup-intent
Snapshot not found Timestamp changed or rounded Copy the exact value from the list
ParentNotFound on copy Destination folder is missing Create each directory level first
Previous Versions is empty No snapshots on the share, or a path issue List snapshots with the CLI; open the mounted share or subfolder
Can't delete a share because it has snapshots Snapshots are protecting it Leave it unless the delete is approved
Restored files have the wrong permissions Copied without ACLs Use robocopy with S in /COPY, or restore from backup

Prevent it next time

Enable soft delete and check the result:

az storage account file-service-properties update -g $RG -n $SA \
  --enable-delete-retention true --delete-retention-days 30

az storage account file-service-properties show -g $RG -n $SA \
  --query shareDeleteRetentionPolicy

Take a manual snapshot before a bulk change:

az storage share-rm snapshot -g $RG --storage-account $SA -n $SHARE
  • Put production shares in an Azure Backup policy. Snapshot-tier recovery points live with the share, while vaulted backups are kept in the vault and survive loss of the source account.
  • Add a CanNotDelete lock to the storage account. It helps protect the account and control-plane deletes, but not files deleted through the mounted share.
  • Use separate admin accounts, and keep delete rights away from daily user accounts where possible.
  • Restore one folder each quarter and record how long it took.