SOURCE
All the code below is freely available on the internet. I first saw it in the SQL2000 SDK from where it has been improved many-many-times-over. Rather than rehash the implementation here is my handover notes.
OVERVIEW OF THIS PROJECT
Transaction-logs (Tlogs) from the London database âActionsâ are backed up every hour to a warm standby in Paris and restored there.
DETAILS
Hourly a SQL Job in London (âLog ship Incidents to Parisâ) executes a stored procedure (âsp_ShipLogOnceâ) that backs up the Tlog directly to Paris (to E:Backups shared as âBackup$â) then runs the Paris SQL Job (âsp_ApplyStandByLogâ) that restores it.
MAINTENANCE & LIMITATIONS
There is a Windows batch file on Paris (âPurgeFilesExceptRecent.batâ) that will delete old Tlogs every 2am. It has been initially set to ignore the newest 720 (being one per hour for 30 days).
Logins on Paris need to be regularly updated from London (at least monthly). The stored procedure âsp_help_revloginsâ will script out the London logins, from which any new, sql, non-svc, entries should be added to Paris.
The Tlogs need to be restored in strict order. After a temporary network failure all outstanding Tlogs can be restored by running this command at Paris …
C:ApplyStandbyLogs.bat E:Data S:Backups
Alternatively individual Tlog can be restored using the stored procedure …
exec Sp_ApplyStandByLog
@DBName=âActionsâ,
@BackupFileName=âS:BackupsActions[name.trn]â,
@UndoFile=âT:DATAActions_undo.ldfâ,
@MoveFileTo=âS:BackupsActionsRestoredâ
SWITCHING ROLES
- Disable the London LogShip job
- Apply final Tlog (sp_ShipLogOnce with @LocalUndoFile)
- Change Paris âActionsâ database to read/write, multi-user
- Enable the Paris LogShip job
DISASTER RECOVERY
If London is unavailable, only step-3 above is needed. IE:-
exec sp_dboption 'actions', 'dbo use only', 'false'
go
exec sp_dboption 'actions', 'read only', 'false'
go
restore database actions with recovery
go