Monitor Database Restore progress at more granular level

Published Mar 30 2022 04:58 AM 2,041 Views
Microsoft

Database Backup & Restore capabilities are crucial for ensuring Business continuity and Disaster recovery.  Restore database operation is usually done in critical situations where a user is trying to restore a database to a stable/known state. In such critical situations users would want to track the progress accurately so that they can plan for subsequent actions and/or alternatives.

 

Currently in Azure SQL DB, you can view the database restore progress either using Portal or using T-SQL by querying a DMV called sys. dm_operation_status. Both portal and DMV currently display restore progress as follows:

  1. Portal displays whether the database restore is “Restoring”(restore in progress) or “Online”(restore is complete)
  2. Sys.dm_operations_status DMV has a column called percent_complete which displays 3 states:
    • 0 = Operation not started
    • 50 = Operation in progress
    • 100 = Operation complete

This information is useful to understand whether the restore operation is in progress, but in many scenarios where the size of operation is big and time consuming, this information does not give granular details of the progress and how much more time is the operation expected to take. As a result, users start to second guess if the operation is running successfully. 

 

To solve this problem, percent_column in sys.dm_operation_status DMV has been enhanced to display the progress of Database Restore operation at a more granular level. percent_complete column in sys.dm_operation_status DMV will now show percent progress as a continuous value from 0 to 99 instead of 50 earlier. Restore is a multi-phase process and state_desc column in sys.dm_operation_status DMV contains phase information. Percent progress range is distributed across these phases based on the size of operations in each phase.

 

New values for percent_complete column for Database Restore operation are as follows:

  • 0 = Operation not started
  • 1-99 = Operation in progress and indicates how far along the operation is, in percent.
  • 100 = Operation complete

 

Here is a sample T-SQL query to view the status of a Restore operation:

 

 

Select * from sys.dm_operation_status 
where operation like '%Restore%' 
order by Start_Time Desc;

 

 

 

Current Preview Limitations

  • Please note the updated values for percent_complete column is applicable for Restore Database operation only in Azure SQL DB all tiers including Hyperscale. It is not applicable for Azure SQL Managed Instance(MI).
  • Currently T-SQL is the only supported way to view accurate progress for restore operation. Updates to Portal, PowerShell and CLI are on Roadmap.

 

Learn more about sys.dm_operation_status and updated percent_complete column.

%3CLINGO-SUB%20id%3D%22lingo-sub-3268577%22%20slang%3D%22en-US%22%3EMonitor%20Database%20Restore%20progress%20at%20more%20granular%20level%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3268577%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-sql%2Fdatabase%2Frecovery-using-backups%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3EDatabase%20Backup%20%26amp%3B%20Restore%3C%2FA%3E%20capabilities%20are%20crucial%20for%20ensuring%20Business%20continuity%20and%20Disaster%20recovery.%20%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fazure-sql%2Fdatabase%2Frecovery-using-backups%22%20target%3D%22_self%22%20rel%3D%22noopener%20noreferrer%22%3ERestore%20database%3C%2FA%3E%20operation%20is%20usually%20done%20in%20critical%20situations%20where%20a%20user%20is%20trying%20to%20restore%20a%20database%20to%20a%20stable%2Fknown%20state.%20In%20such%20critical%20situations%20users%20would%20want%20to%20track%20the%20progress%20accurately%20so%20that%20they%20can%20plan%20for%20subsequent%20actions%20and%2For%20alternatives.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ECurrently%20in%20Azure%20SQL%20DB%2C%20you%20can%20view%20the%20database%20restore%20progress%20either%20using%20Portal%20or%20using%20T-SQL%20by%20querying%20a%20DMV%20called%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fsystem-dynamic-management-views%2Fsys-dm-operation-status-azure-sql-database%3Fview%3Dazuresqldb-current%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Esys.%20dm_operation_status%3C%2FA%3E.%20Both%20portal%20and%20DMV%20currently%20display%20restore%20progress%20as%20follows%3A%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EPortal%20displays%20whether%20the%20database%20restore%20is%20%E2%80%9CRestoring%E2%80%9D(restore%20in%20progress)%20or%20%E2%80%9COnline%E2%80%9D(restore%20is%20complete)%3C%2FLI%3E%0A%3CLI%3ESys.dm_operations_status%20DMV%20has%20a%20column%20called%20percent_complete%20which%20displays%203%20states%3A%3C%2FLI%3E%0A%3CUL%3E%0A%3CLI%3E0%20%3D%20Operation%20not%20started%3C%2FLI%3E%0A%3CLI%3E50%20%3D%20Operation%20in%20progress%3C%2FLI%3E%0A%3CLI%3E100%20%3D%20Operation%20complete%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FOL%3E%0A%3CP%3EThis%20information%20is%20useful%20to%20understand%20whether%20the%20restore%20operation%20is%20in%20progress%2C%20but%20in%20many%20scenarios%20where%20the%20size%20of%20operation%20is%20big%20and%20time%20consuming%2C%20this%20information%20does%20not%20give%20granular%20details%20of%20the%20progress%20and%20how%20much%20more%20time%20is%20the%20operation%20expected%20to%20take.%20As%20a%20result%2C%20users%20start%20to%20second%20guess%20if%20the%20operation%20is%20running%20successfully.%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ETo%20solve%20this%20problem%2C%20percent_column%20in%20sys.dm_operation_status%20DMV%20has%20been%20enhanced%20to%20display%20the%20progress%20of%26nbsp%3B%3CSTRONG%3EDatabase%20Restore%3C%2FSTRONG%3E%20operation%20at%20a%20more%20granular%20level.%20percent_complete%20column%20in%20sys.dm_operation_status%20DMV%20will%20now%20show%20percent%20progress%20as%20a%20continuous%20value%20from%200%20to%2099%20instead%20of%2050%20earlier.%20Restore%20is%20a%20multi-phase%20process%20and%20state_desc%20column%20in%20sys.dm_operation_status%20DMV%20contains%20phase%20information.%20Percent%20progress%20range%20is%20distributed%20across%20these%20phases%20based%20on%20the%20size%20of%20operations%20in%20each%20phase.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ENew%20values%20for%20percent_complete%20column%20for%20Database%20Restore%20operation%20are%20as%20follows%3A%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E0%20%3D%20Operation%20not%20started%3C%2FLI%3E%0A%3CLI%3E1-99%20%3D%20Operation%20in%20progress%20and%20indicates%20how%20far%20along%20the%20operation%20is%2C%20in%20percent.%3C%2FLI%3E%0A%3CLI%3E100%20%3D%20Operation%20complete%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EHere%20is%20a%20sample%20T-SQL%20query%20to%20view%20the%20status%20of%20a%20Restore%20operation%3A%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-sql%22%3E%3CCODE%3ESelect%20*%20from%20sys.dm_operation_status%20%0Awhere%20operation%20like%20'%25Restore%25'%20%0Aorder%20by%20Start_Time%20Desc%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSTRONG%3ECurrent%20Preview%20Limitations%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EPlease%20note%20the%20updated%20values%20for%20percent_complete%20column%20is%20applicable%20for%20Restore%20Database%20operation%20only%20in%20Azure%20SQL%20DB%20all%20tiers%20including%20Hyperscale.%20It%20is%20not%20applicable%20for%26nbsp%3BAzure%20SQL%20Managed%20Instance(MI).%3C%2FLI%3E%0A%3CLI%3ECurrently%20T-SQL%20is%20the%20only%20supported%20way%20to%20view%20accurate%20progress%20for%20restore%20operation.%20Updates%20to%20Portal%2C%20PowerShell%20and%20CLI%20are%20on%20Roadmap.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3ELearn%20more%20about%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Frelational-databases%2Fsystem-dynamic-management-views%2Fsys-dm-operation-status-azure-sql-database%3Fview%3Dazuresqldb-current%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Esys.dm_operation_status%20and%20updated%20percent_complete%20column%3C%2FA%3E.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-3268577%22%20slang%3D%22en-US%22%3E%3CP%3EWe%20are%20excited%20to%20announce%20Preview%20of%20Database%20Restore%20Progress%20Feature%20that%20lets%20you%20track%20progress%20of%20Database%20restore%20operation%20at%20a%20more%20granular%20level%20-%20Learn%20more.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3268577%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%20SQL%20Database%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Co-Authors
Version history
Last update:
‎Mar 30 2022 04:57 AM
Updated by: