SHARE
Facebook X Pinterest WhatsApp

Displaying Backup or Restore Progress

Written By
thumbnail
Gregory Larsen
Gregory Larsen
Apr 3, 2017

Have you ever started a database backup or a restore process that runs a long time then wanted to know when it will complete?   If you have then there is an easily way to do this.  Knowing when a database backup or restore operation will completes provides you valuable information, especially when you need to perform follow-on tasks that are waiting for the backup or restore process to complete.

In order to show the backup or restore status you can run the following TSQL statement:

SELECT session_id as SPID, command, a.text AS Query, start_time, percent_complete, 
      dateadd(second,estimated_completion_time/1000, getdate()) as estimated_completion_time 
FROM sys.dm_exec_requests r CROSS APPLY sys.dm_exec_sql_text(r.sql_handle) a 
WHERE r.command in ('BACKUP DATABASE','RESTORE DATABASE'); 

By reviewing this query you can see it is using sys.dm_exec_requests and sys.dm_exec_sql_text to retrieve information for “BACKUP DATABASE” or “RESTORE DATABASE” commands.

Below is a sample of the output from this command that I have reformatted for readability:

SPID   command                          Query                                                                                                                                                                                                                                                            
------ -------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------- 
60     BACKUP DATABASE                  BACKUP DATABASE [AdventureWorks2016CTP3] TO  DISK = N'C:AdventureWorks2016CTP3.bak' WITH NOFORMAT, NOINIT,  NAME = N'AdventureWorks2016CTP3-Full Database Backup', SKIP, NOREWIND, NOUNLOAD,  STATS = 10                                       
 
 
start_time                         percent_complete     estimated_completion_time
-----------------------            ----------------     -------------------------
2017-03-19 10:11:51.630            43.9362              2017-03-19 10:12:13.460

By reviewing the “percent_complete” column above you can see my backup is 43.9362 percent complete, and then by using the “estimated_completion_time” column you can tell my backup will complete around 10:12:13.460.  You can use the “Query” column  in the output to see the actual BACKUP command that was used to back up my Adventure Works2016CTP3 database.

See all articles by Greg Larsen

Recommended for you...

Best Online Courses to Learn SQL
Ronnie Payne
Sep 23, 2022
Best Courses for Database Administrators
Ronnie Payne
Jul 22, 2022
Tip 74 – Changing Cost Threshold for Parallelism
Gregory Larsen
Feb 24, 2021
How Many Databases Can You Name?
Brad Jones
May 11, 2020
Database Journal Logo

DatabaseJournal.com publishes relevant, up-to-date and pragmatic articles on the use of database hardware and management tools and serves as a forum for professional knowledge about proprietary, open source and cloud-based databases--foundational technology for all IT systems. We publish insightful articles about new products, best practices and trends; readers help each other out on various database questions and problems. Database management systems (DBMS) and database security processes are also key areas of focus at DatabaseJournal.com.

Property of TechnologyAdvice. © 2025 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.