SQL Server ‐ Reinitialize log shipping - shaysalomon12/Data-Engineer GitHub Wiki
1. Removing Current Log Shipping Configuration
On the Primary Server (USSQL)
This will generate the commands to run on the primary server:
select STEP1='USE master;' + CHAR(13) +
'EXEC master.dbo.sp_delete_log_shipping_primary_secondary' + char(13) +
' @primary_database = N' + '''' + a.primary_database + '''' + char(13) +
',@secondary_server = N' + '''' + '<secondary_server_ip>' + '''' + char(13) +
',@secondary_database = N' + '''' + a.primary_database + '''' + char(13)
,STEP2='USE master;' + CHAR(13) +
'EXEC master.dbo.sp_delete_log_shipping_primary_database @database= N'
+ '''' + a.primary_database + '''' + char(13)
,*
from msdb.dbo.log_shipping_primary_databases a
where primary_database = '<database_name>';
Or use this link
For example, to reinitialize Log Shipping for cetgroups3:
Verify cetgroups3 settings:
select * from msdb.dbo.log_shipping_primary_databases;
select STEP1='USE master;' + CHAR(13) +
'EXEC master.dbo.sp_delete_log_shipping_primary_secondary' + char(13) +
' @primary_database = N' + '''' + a.primary_database + '''' + char(13) +
',@secondary_server = N' + '''' + 'bsql' + '''' + char(13) +
',@secondary_database = N' + '''' + a.primary_database + '''' + char(13)
,STEP2='USE master;' + CHAR(13) +
'EXEC master.dbo.sp_delete_log_shipping_primary_database @database= N'
+ '''' + a.primary_database + '''' + char(13)
,*
from msdb.dbo.log_shipping_primary_databases a
where primary_database = 'cetgroups3';
We will get:
-- STEP1:
USE master;
GO
EXEC master.dbo.sp_delete_log_shipping_primary_secondary
@primary_database = N'cetgroups3'
,@secondary_server = N'bsql'
,@secondary_database = N'cetgroups3';
GO
-- STEP2:
USE master;
GO
EXEC master.dbo.sp_delete_log_shipping_primary_database @database= N'cetgroups3';
GO
Verify cetgroups3 was removed from settings:
select * from msdb.dbo.log_shipping_primary_databases;
On the Secondary Server (BSQL):
Verify existing settings for cetgroups3 and remove it:
USE master;
GO
select * from msdb.dbo.log_shipping_secondary_databases;
exec sp_delete_log_shipping_secondary_database @secondary_database = N'cetgroups3';
GO
Verify cetgroups3 settings are removed:
select * from msdb.dbo.log_shipping_secondary_databases;
2. Setting New Log Shipping Configuration
Once all Log Shipping settings for the database are removed, it's time to configure a new Log Shipping.
On the Primary Server (USSQL)
Connect to Primary Server, expand databases, right click the database we want to configure for Log Shipping and choose properties. Go to "Transaction Log Shipping" and start configuring Log Shipping:
- primary_database:
cetgroups3
- backup_directory:
\\bsql\Log_Shipping\cetgroups3
- backup_share:
\\bsql\Log_Shipping\cetgroups3
- backup_retention_period: 7200
Database Properties - cetgroups3
Transaction Log Backup Settings
Secondary Database Settings - Copy Files
Secondary Database Settings - Restore Transaction Log
When done with configuration settings click "ok" and wait for the process to finish:
For a more detailed steps see here: