Victor protects a file share, takes a recovery point, deletes the file, and watches the restore job return it.
Backup vs. redundancy vs. a snapshot you took once
Storage redundancy (LRS/ZRS/GRS) keeps extra copies of your data against a hardware failure — but it faithfully replicates a deletion or a ransomware encryption too, because it does not know the change was a mistake. A one-off snapshot is better, but nobody remembers to take them and nobody knows when the last one was. Azure Backup is the discipline in between: a policy takes recovery points on a schedule and keeps them for a set retention, in a Recovery Services vault that lives apart from the data it protects. This lab runs the whole loop on an Azure Files share — the cheapest, fastest workload that still teaches vault, policy, recovery point, and, the part that actually matters, the restore.
A backup you never restore is a rumour.
You need a free Azure account and the Azure CLI (az), signed in with az login. First time? The 15-minute Set up your machine page covers the account, the installs, and sign-in. Prefer zero installs? Run everything in Azure Cloud Shell (Bash), preinstalled and already signed in.
This is not strictly free tier: protecting a file share carries a small protected-instance charge plus a few pennies of snapshot storage. Run start-to-finish and tear down the same day and it costs roughly a few cents — but if you leave it running, that becomes a few dollars a month. The teardown section removes everything. Pairs with Class 36d — Azure Backup.
A file share worth protecting
Create a storage account, a small file share, and drop one file in it — the thing you will later "lose."
# Windows/Git Bash: stop it mangling resource-id arguments (harmless on macOS/Linux) export MSYS_NO_PATHCONV=1 SUFFIX=$RANDOM RG="campux-lab-dr-rg" LOCATION="eastus" SA="campuxdr$SUFFIX" # 3-24 lowercase alphanumeric SHARE="campuxfiles" VAULT="campux-dr-vault" POLICY="campux-afs-policy" az group create --name "$RG" --location "$LOCATION" -o table az storage account create --name "$SA" --resource-group "$RG" \ --location "$LOCATION" --sku Standard_LRS --kind StorageV2 -o none az storage share-rm create --resource-group "$RG" \ --storage-account "$SA" --name "$SHARE" --quota 1 -o none # upload one throwaway file, using an account key KEY=$(az storage account keys list -g "$RG" -n "$SA" --query "[0].value" -o tsv) echo "The quarterly numbers nobody wants to lose." > payroll.csv az storage file upload --account-name "$SA" --account-key "$KEY" \ --share-name "$SHARE" --source payroll.csv -o none
az storage file list --account-name "$SA" --account-key "$KEY" --share-name "$SHARE" -o table shows payroll.csv.A vault and a backup policy
The vault holds recovery points apart from the share. Set its redundancy while it is empty (you cannot change it once backups exist), then build a file-share policy from the built-in default template so you do not have to hand-write the schedule JSON.
az backup vault create --resource-group "$RG" --name "$VAULT" \ --location "$LOCATION" -o table # cheaper local redundancy for a throwaway lab — must run before any backup item exists az backup vault backup-properties set --name "$VAULT" --resource-group "$RG" \ --backup-storage-redundancy LocallyRedundant # export the built-in default policy, then create our file-share policy from it az backup policy show --resource-group "$RG" --vault-name "$VAULT" \ --name DefaultVaultPolicy > afs-policy.json az backup policy create --resource-group "$RG" --vault-name "$VAULT" \ --policy afs-policy.json --name "$POLICY" \ --backup-management-type AzureStorage
az backup policy list --resource-group "$RG" --vault-name "$VAULT" --backup-management-type AzureStorage -o table lists campux-afs-policy.The built-in template name can vary by vault. If the policy show line errors, list what the vault already has — az backup policy list --resource-group "$RG" --vault-name "$VAULT" -o table — and export whichever policy it names instead, or skip the create entirely and pass an existing AzureStorage policy name straight to --policy-name in Step 3.
Protect the share, then take a recovery point
Enable protection, then trigger an on-demand backup rather than waiting for the schedule — you want a recovery point in hand and you want to watch a job finish.
az backup protection enable-for-azurefileshare \
--vault-name "$VAULT" --resource-group "$RG" \
--policy-name "$POLICY" --storage-account "$SA" \
--azure-file-share "$SHARE" -o table
# capture the exact container + item names the later commands need
CONTAINER=$(az backup container list --resource-group "$RG" --vault-name "$VAULT" \
--backup-management-type azurestorage --query "[0].name" -o tsv)
ITEM=$(az backup item list --resource-group "$RG" --vault-name "$VAULT" \
--backup-management-type azurestorage --query "[0].name" -o tsv)
az backup protection backup-now \
--vault-name "$VAULT" --resource-group "$RG" \
--container-name "$CONTAINER" --item-name "$ITEM" \
--retain-until 31-12-2026 -o table
az backup job list --resource-group "$RG" --vault-name "$VAULT" -o table. When the Backup operation reads Completed, you hold a real recovery point. (A file-share backup usually finishes in a minute or two.)Stage the disaster: delete the file
Now lose it — the deleted spreadsheet, the fat-fingered delete, the everyday incident that item-level restore exists for.
az storage file delete --account-name "$SA" --account-key "$KEY" \
--share-name "$SHARE" --path payroll.csv
az storage file exists --account-name "$SA" --account-key "$KEY" \
--share-name "$SHARE" --path payroll.csv --query exists # -> false
exists query returns false. The live share no longer has the file — but the vault still does.Restore it from the vault
Find the recovery point and restore just that one file back to its original location.
# the newest recovery point
RP=$(az backup recoverypoint list --vault-name "$VAULT" --resource-group "$RG" \
--container-name "$CONTAINER" --item-name "$ITEM" \
--backup-management-type azurestorage --workload-type azurefileshare \
--query "[0].name" -o tsv)
az backup restore restore-azurefiles \
--vault-name "$VAULT" --resource-group "$RG" --rp-name "$RP" \
--container-name "$CONTAINER" --item-name "$ITEM" \
--restore-mode originallocation \
--source-file-type file --source-file-path "payroll.csv" \
--resolve-conflict overwrite -o table
Restore job to read Completed in az backup job list ... -o table, then re-run the exists check: az storage file exists --account-name "$SA" --account-key "$KEY" --share-name "$SHARE" --path payroll.csv --query exists now returns true. The identical share that was missing the file has it back — the only thing that changed was a restore job. That is the entire lesson.Tear it down (mind soft delete)
Stop protection and clear the backup data, then remove the group. Soft delete is the trap here: a vault holding soft-deleted recovery points refuses to be deleted, so disable it first.
# disable soft delete so the cleared data is gone immediately, not held ~14 days az backup vault backup-properties set --name "$VAULT" --resource-group "$RG" \ --soft-delete-feature-state Disable az backup protection disable \ --vault-name "$VAULT" --resource-group "$RG" \ --container-name "$CONTAINER" --item-name "$ITEM" \ --backup-management-type azurestorage --workload-type azurefileshare \ --delete-backup-data true --yes -o table az group delete --name "$RG" --yes az group exists --name "$RG" # -> false
That is soft delete doing its job: the vault still holds recovery points in a soft-deleted state and will not delete until they are cleared. Confirm soft delete is Disabled (az backup vault backup-properties show -n "$VAULT" -g "$RG"), re-run the protection disable ... --delete-backup-data true step, then delete the group again.
What you can now honestly claim
You created a Recovery Services vault, built a backup policy, protected an Azure Files share, took an on-demand recovery point, and — the part most engineers never do — actually restored, returning a deleted file from the vault to its original place. You know a vault stores recovery points apart from what they protect, that a policy is a schedule plus a retention, and that soft delete guards the backups themselves (and blocks a careless teardown). The same loop scales up: a full share restore, a full VM restore, or a cross-region restore where the vault is GRS. The one DR step this lab deliberately skips is an Azure Site Recovery test failover — it needs replicated VMs and target-region compute, so Class 36e — Azure Site Recovery covers it as a walkthrough rather than a paid exercise.