Restore a database to an earlier point in time
In this task you'll restore an Azure SQL database to an earlier point in time.
Azure SQL backs up every database automatically and keeps the backups for 7 days by default. With point-in-time restore you can create a copy of the database as it was at any moment in that window, down to the minute.
A restore never overwrites the original. It creates a new database next to it, so you can compare, copy back what you need, and then remove whichever one you don't want.
Example. An Ironbridge Payments developer runs an UPDATE without a WHERE clause at 14:05. The team restores the database as it was at 14:00 under a new name, copies the correct values back, and deletes the copy.
Before you start
You need: SQL DB Contributor or Contributor. Time: 15 minutes, plus waiting.
Where to look
- SQL databases
- db-practice
- Overview
- Restore
Steps
- In Query editor, make a mistake on purpose:
DELETE FROM Products;then check withSELECT * FROM Products;that the table is empty.Note the time before you did this. - Go to the database's Overview and select Restore.
- Choose a restore point a few minutes before the delete, and name the new database db-practice-restored.The earliest point is shortly after the database was created, so do this task some time after the previous one.
- Check the cost shown on the Review page.The restored copy may not be covered by the free offer, so delete it as soon as you've finished.
- Select Review + create, then Create. Restoring takes a few minutes or more: a small free-offer database took about 40 minutes, and one created the same day can take well over an hour.While it runs, the new database doesn't appear in the server's list of databases yet.
- Open db-practice-restored in Query editor and run
SELECT * FROM Products;. Both rows are back.
Commands
# Restore a copy of the database as it was at a given time (UTC)
az sql db restore --resource-group rg-portal-practice --server sql-portal-<initials> \
--name db-practice --dest-name db-practice-restored \
--time "2026-10-17T14:00:00Z"
# Delete the copy again
az sql db delete --resource-group rg-portal-practice --server sql-portal-<initials> \
--name db-practice-restored --yes
Watch out for
- Cost
- Backups within the default retention are included. The restored copy is a new database with its own charges, so delete it once you've copied what you need.
- Security
- Anyone who can restore can see all the data as it was. Treat the copy with the same care as the original, and delete it when it's no longer needed.
- Common mistakes
- Thinking the query editor is broken when a paused free-offer database times out on the first query: it's waking up, so run it again. Expecting the restore to fix the original database in place. Waiting longer than the retention period. Forgetting about a restored copy, which keeps costing money.
Clean up
- SQL databases
- db-practice-restored
- Delete
Delete db-practice-restored straight away: open it, select Delete and confirm. The rest goes with the resource group at the end of this section.
Words to know
- Point-in-time restore
- Creating a copy of a database as it was at a chosen moment in the past.
- Retention period
- How long automatic backups are kept: 7 days by default, up to 35.
- Long-term retention
- Keeping weekly, monthly or yearly backups for up to 10 years. Costs extra.
Tick off each step and track your progress in the guide.
Open this task in Azure Portal, Hands On