Technical Article

Backup And Restore Remain Time

,

As a sql developer and now as a dba many times I have to restore or backup the current databases and one too many I get emails or calls from developers of how long before the Restore or the backup is over; Or because of automation I want to check the remain time of a backup or restore process. Well now I have a way to know.

use master
go

SELECT
    percent_complete,
    start_time ,
    command, 
    b.name AS DatabaseName, --Most of the time will said Main but this is because db is not accesible
    DATEADD(ms,estimated_completion_time,GETDATE()) AS RemainTime,
    (estimated_completion_time/1000/60) AS MinutesToFinish

    FROM sys.dm_exec_requests a
    INNER JOIN sys.databases b 
    ON a.database_id = b.database_id
    WHERE command like '%restore%'
    or command like '%Backup%'
    AND estimated_completion_time > 0

Rate

3.33 (3)

You rated this post out of 5. Change rating

Share

Share

Rate

3.33 (3)

You rated this post out of 5. Change rating