Wednesday, April 25, 2012

Logshipping - FAQ

What recovery models will support Logshipping
FULL & BULK-LOGGED

What will happen if we change the recovery model of a logshipping database?
If we change it from Full to Bulk Logged, nothing will happen. The T-log files will generate as usual.
If we change it back from Bulk Logged to Full also no issues.
If we change it from Full to Simple and simple to full then it wont generate logbackups from that point onwards.

Example Scenario:
backup log mydatabase to disk='c:\temp\mydatabase_log1.trn' log mydatabase to disk='c:\temp\mydatabase_log1.trn'
alter database mydatabase Set recovery bulk_logged
select name, recovery_model from sys.databases where name ='mydatabase'
backup log mydatabase to disk='c:\temp\mydatabase_log2.trn'
alter database mydatabase Set recovery Full
select name, recovery_model from sys.databases where name ='mydatabase'
backup log mydatabase to disk='c:\temp\mydatabase_log3.trn'
alter database mydatabase Set recovery Simple
select name, recovery_model from sys.databases where name ='mydatabase'
alter database mydatabase Set recovery Full
select name, recovery_model from sys.databases where name ='mydatabase'
backup log mydatabase to disk='c:\temp\mydatabase_log4.trn'

Then we will get the below error message

Msg 4214, Level 16, State 1, Line 1
BACKUP LOG cannot be performed because there is no current database backup.
Msg 3013, Level 16, State 1, Line 1
BACKUP LOG is terminating abnormally.

To Restart the logshipping what needs to be done ?

1) Need to generate full backup to generate logs  -- It will take huge time based ont the size of the database.
2) Simple way is generate a differential backup -- Which allows to generate logs again, no need to generate full backup.

backup database mydatabase to disk='c:\temp\mydatabase_differential1.dif' with differential database mydatabase to disk='c:\temp\mydatabase_differential1.dif' with differential

backup log mydatabase to disk='c:\temp\mydatabase_log5.trn'

No comments: