1

Is there any way that I can identify when a database is restored on the server? I created a server trigger but only triggers when I create a new database not after is restored from another one.

I'm using SQL Server 2014, trying to achieve this using MSMS, using msdb.dbo.restorehistory is good but I don't want to create a job for that, trying to find something straightforward

I want to know as s DBA when any database is created or restored, just for control.

I found that there is no DDL trigger for RESTORE, there is however Event Notification for the AUDIT_BACKUP_RESTORE_EVENT but I didn't find any good example of how to use it.

could someone tell me which accounts I need to merge? I'm confuse, I did it with my account on stackoverflow and it says is already linked and I can't continue

2

1 Answer 1

3

Under the assumption that you are using SQL Server, you can create a trigger against the msdb..restorehistory table.

Go ahead and query that table to see what information is in there; I think you can achieve what you are doing.

See Know when a database has been restored

1
  • 1
    +1 Of course one small gotcha with that approach is rows can be inserted into msdb.dbo.restorehistory when performing various RESTORE operations such as 'RESTORE VERIFYONLY` etc.
    – Hannah Vernon
    Mar 21, 2017 at 22:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.