Thursday, 5 February 2015

How to check backup or restore time completion

We may have different way to check completion time Backup/Restore databases using DMV's
I have simple query here.


SELECT
              percent_complete  AS [Completed (%)]
              ,command  AS [Activity]
              ,start_time  AS [ActivityStartTime]
              ,d.name  AS [DatabaseName]
              ,DATEADD(MS,estimated_completion_time ,GETDATE()) AS [TotalTimeRemaining]
              ,(estimated_completion_time /1000/60) AS [RemainingTimeInMins]
              ,(estimated_completion_time /1000) AS [RemainingTimeInSecs]
FROM sys.dm_exec_requests r --ER
INNER JOIN sys.databases d  --sd
ON r.database_id  = d.database_id
WHERE command  LIKE '%RESTORE%'
OR command  LIKE '%BACKUP%'
AND estimated_completion_time  > 0

GO

No comments:

Post a Comment