Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Problems doing point in time recovery Expand / Collapse
Author
Message
Posted Wednesday, June 25, 2014 4:45 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, July 22, 2014 3:04 AM
Points: 43, Visits: 122
Hi,

I have a database which has one full back and 3 transaction log backups which were taken straight after the full backup.

As a test, before taking each transaction log backup I made a slight change to my data.

I then go onto my second SQL Server instance and do a restore of the full back and with no recovery.

This works fine.

Then I do a restore using a transaction log.

If I restore using the first transaction log out of the 3 (i.e. - the T log which was backed up straight after the full backup) then it restores my database successfully with the data.

If I try to restore using the 2nd or 3rd transaction log files it shows the message:-

System.Data.SqlClient.SqlError: The log in this backup set terminates at LSN 30000000010700001, which is too early to apply to the database. A more recent log backup that includes LSN 30000000013400001 can be restored.

So how can I get around this problem and restore my database using the 2nd or 3rd transaction log files?

My database has a Recovery Model of FULL.

Thanks.
Post #1585816
Posted Wednesday, June 25, 2014 4:52 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 9:55 AM
Points: 5,233, Visits: 9,463
You have to restore all log backups in the chain, not just the most recent. So if you want to bring the database to the latest point possible using the backups you have, you need to restore the full backup with norecovery, then the first log backup with norecovery, then the second, then the third. You can run RESTORE DATABASE MyDB WITH RECOVERY at the very end.

John
Post #1585818
Posted Wednesday, June 25, 2014 4:59 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, July 22, 2014 3:04 AM
Points: 43, Visits: 122
I see.

I'll give it a try, thanks.
Post #1585819
Posted Wednesday, June 25, 2014 5:06 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, July 22, 2014 3:04 AM
Points: 43, Visits: 122
Was just wondering, is there no way for me to specify a specific date and time while doing the restore.

If for example I had 40 transaction log backups and wanted the latest log to be restored does this mean I would have to restore 39 transaction logs with norecovery (which were backed up previously) before I could reach the one I want?

Is there not a quicker way of doing this instead of going through and restoring one at a time?
Post #1585824
Posted Wednesday, June 25, 2014 5:10 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 9:55 AM
Points: 5,233, Visits: 9,463
Yes, it does mean that. If that's going to be a problem for you, consider taking differential backups. These backup every page (or maybe extent) that has been altered since the last full backup. So your recovery plan would then be: restore full with norecovery, restore latest diff with no recovery, restore all log backups since latest diff with no recovery, recover database.

John
Post #1585826
Posted Wednesday, June 25, 2014 5:30 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, July 22, 2014 3:04 AM
Points: 43, Visits: 122
Apologies for all the questions but what if the transaction logs backups were not generating a new file each time the backup takes place.

But instead appending the existing .trn file.

This would mean I would only have one file containing all of my T log backups in it.

Would I then be able to backup all of the transaction logs in one restore using this method?

Also on this note how can I change the settings to either generate a new log file each time the backup takes place or to keep the same file?

Thanks.
Post #1585837
Posted Wednesday, June 25, 2014 5:33 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 11:13 AM
Points: 15,527, Visits: 27,909
I wrote an article a while back here on SQL Server Central that covers a lot of the questions here.

----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1585839
Posted Wednesday, June 25, 2014 5:40 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 9:55 AM
Points: 5,233, Visits: 9,463
Grant's link doesn't work (for me, anyway), so I'll attempt to answer your questions briefly (although you probably could answer them yourself with a bit of search engine magic).

First, no, you still have to restore them one by one. Check out the RESTORE documentation for the syntax for multiple backup sets on one device.

Second, it depends how you're doing your backups in the first place. Check out the BACKUP documentation, use maintenance plans or try Ola Hallengren's universally acclaimed scripts.

John
Post #1585842
Posted Wednesday, June 25, 2014 5:59 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: Today @ 11:13 AM
Points: 15,527, Visits: 27,909
Weird. Not sure why that's not coming up. Here's another one from Jonathan Kehayias.

----------------------------------------------------
"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of: SQL Server 2012 Query Performance Tuning
SQL Server 2008 Query Performance Tuning Distilled
and
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #1585845
Posted Wednesday, June 25, 2014 6:54 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Tuesday, July 22, 2014 3:04 AM
Points: 43, Visits: 122
Thanks guys for your answers.

I'll have a read through that article (I can see it).
Post #1585870
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse