

****** End: Script to be run at Primary: ****** !!del $(PBKSHARE)$(DATABASE)_dr_init.bak /Q

!!copy $(PBKSHARE)$(DATABASE)_dr_init.bak $(SBKSHARE) /y Print 'copy $(PBKSHARE)$(DATABASE)_dr_init.bak $(SBKSHARE) /y' Print '$(PBKSHARE)$(DATABASE)_dr_init.bak' :setvar SDATADIR "D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\"Īlter database set recovery fullĮXEC = 1ĮXEC = OUTPUTĮXEC _add_log_shipping_alert_jobīackup database to disk = '$(PBKDIR)$(DATABASE)_dr_init.bak' with init :setvar SBKSHARE "\\secondary\d$\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\BACKUP\" :setvar PBKSHARE "\\primary\d$\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\BACKUP\" :setvar PBKDIR "D:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\BACKUP\" ****** Begin: Script to be run at Primary: ****** The script needs to be run at the Primary in the context of the database. Execute the following statements at the Primary to configure Log Shipping As a bonus you can also execute OS commands (copy, del, etc.) so you can script out the backup and restore as well. This can be accomplished by used the SQLCMD mode commands of SQLCMD using the CONNECT command, making sure to put GOs between the connections. The only obstacle to overcome in the script that it generates will need to connect to both the primary and the secondary in the same script. This is totally possible, and it can be scripted out through the log shipping setup GUI.
