I assume the Primary server is R1, the Secondary is R2
- Alerts (Both on Primary R1 and Secondary R2)
- Backup (On Primary)
- Copy (On Secondary)
- Restore (On Secondary)
Limitation:
In order to be compatible with SQL 2005 ( no default value for T-SQL variable), I changed the code script method.
A lot of posts that used “RESTORE FILELISTONLY” and “BackupSet” table to grab backup files.
Yes, I agree it would be more accurate for latest backup and correct LSN/DB logical name. But if someone drop/detach DB and left backup histories and backup files. It would be incorrect. Additional, sometimes when you use “RESTORE FILELISTONLY” to grab backup files, it will show “Access Denied” message.
In order to avoid the problem, I use “sys.Master_files” table to match “Backupset” and “BackupsetMediafamily”.