December 17, 2008 at 9:40 am
Hi,
I am looking for a way, via code, to determine if a backup process is currently running.
I know that msdb.backupset contains backup_startDate and backup_endDate fields, but it seems like a record is only entered into that table when a backup has completed. (I was hoping I would see something like a value for the startDate but NULL for the endDate...no such luck.)
Does anyone have any suggestions?
thanks very much,
Ken
December 17, 2008 at 10:08 am
you could query the sysprocesses table, if there were any backups running the column 'cmd' would have an entry of 'backup database'
---------------------------------------------------------------------
December 17, 2008 at 1:22 pm
Hey I post the below code but here it is :
enjoy
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
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply