SQL-Server: Is there a SQL script that I can use to determine the progress of a SQL Server backup or restore process?

前端 未结 17 1283
独厮守ぢ
独厮守ぢ 2020-12-04 06:16

When I backup or restore a database using MS SQL Server Management Studio, I get a visual indication of how far the process has progressed, and thus how much longer I still

相关标签:
17条回答
  • 2020-12-04 06:51

    Use STATS option: http://msdn.microsoft.com/en-us/library/ms186865.aspx

    0 讨论(0)
  • 2020-12-04 06:51

    I am using sp_whoisactive, very informative an basically industry standard. it returns percent complete as well.

    0 讨论(0)
  • 2020-12-04 06:55

    simply run bkp_status on master db you will get backup status

    0 讨论(0)
  • 2020-12-04 06:58

    For anyone running SQL Server on RDS (AWS), there's a built-in procedure callable in the msdb database which provides comprehensive information for all backup and restore tasks:

    exec msdb.dbo.rds_task_status;
    

    This will give a full rundown of each task, its configuration, details about execution (such as completed percentage and total duration), and a task_info column which is immensely helpful when trying to figure out what's wrong with a backup or restore.

    0 讨论(0)
  • 2020-12-04 07:00
    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')
    
    0 讨论(0)
  • 2020-12-04 07:01

    Here's a simple script that generally does the trick for me:

    SELECT command, percent_complete,total_elapsed_time, estimated_completion_time, start_time
      FROM sys.dm_exec_requests
      WHERE command IN ('RESTORE DATABASE','BACKUP DATABASE') 
    
    0 讨论(0)
提交回复
热议问题