Monitor backup and restore progress in SQL Server

If the backup or restore is running from a SQL Agent job or maybe someone kicked off the process from another machine, you can use DMV - sys.dm_exec_requests to find the progress. I really thank Microsoft for introducing DMV's and making a DBA's life a lot easier.
You can run this script, which will give you output simliar to to the screenshot below. Here we can see the percent complete and estimated completion time. This script will work for any backup or restore that is currently running regardless of what method was used to run the backup or restore.

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')









Comments

Popular posts from this blog

VS 2012: No exports were found that match the constraint : ContractName

How to Tweak the New Multi-Monitor Taskbar in Windows 8