The first thing to do with a damaged off-line database

  • Phil Factor

    SSC-Insane

    Points: 20115

    Comments posted to this topic are about the item The first thing to do with a damaged off-line database

    Best wishes,
    Phil Factor
    Simple Talk

  • PRAMANA.DBA

    SSCertifiable

    Points: 5507

    Good Question....

  • twin.devil

    SSC-Insane

    Points: 22208

    Excellent question, Thanks for sharing

  • SQLDoubleG

    Hall of Fame

    Points: 3090

    obviously the first thing should be to backup the log, but what is the point when the database is offline and you will get an error?

    BACKUP LOG [QODTest] TO DISK = 'c:\QODTest_20140718.trn' WITH CONTINUE_AFTER_ERROR

    returns

    Msg 942, Level 14, State 3, Line 2

    Database 'QODTest' cannot be opened because it is offline.

    Msg 3013, Level 16, State 1, Line 2

    BACKUP LOG is terminating abnormally.

    From BOL

    But if the database is in the OFFLINE or EMERGENCY state, BACKUP is not allowed even with NO_TRUNCATE.

    Best practice is to backup the log, but in this case the first thing you should do (imho) is to restore the last full backup (WITH REPLACE), otherwise you're wasting your time executing something that will fail.

  • Hany Helmy

    SSChampion

    Points: 13488

    raulggonzalez (7/18/2014)


    obviously the first thing should be to backup the log, but what is the point when the database is offline and you will get an error?

    BACKUP LOG [QODTest] TO DISK = 'c:\QODTest_20140718.trn' WITH CONTINUE_AFTER_ERROR

    returns

    Msg 942, Level 14, State 3, Line 2

    Database 'QODTest' cannot be opened because it is offline.

    Msg 3013, Level 16, State 1, Line 2

    BACKUP LOG is terminating abnormally.

    From BOL

    But if the database is in the OFFLINE or EMERGENCY state, BACKUP is not allowed even with NO_TRUNCATE.

    Best practice is to backup the log, but in this case the first thing you should do (imho) is to restore the last full backup (WITH REPLACE), otherwise you're wasting your time executing something that will fail.

    That`s why it was mentioned "Try to take a tail-log backup", anyway you made your point clear enough 😎

  • twin.devil

    SSC-Insane

    Points: 22208

    Tail log backup WITH CONTINUE_AFTER_ERROR works only if the database goes offline in case during the start up of the database is fail to come online due to some reasons or damaged due to some reason, in case if we did purpose fully then that will not work (i,e the database didnt have any issues at all)

  • SQLDoubleG

    Hall of Fame

    Points: 3090

    twin.devil (7/18/2014)


    Tail log backup WITH CONTINUE_AFTER_ERROR works only if the database goes offline in case during the start up of the database is fail to come online due to some reasons or damaged due to some reason, in case if we did purpose fully then that will not work (i,e the database didnt have any issues at all)

    True, now I took the time to manually "corrupt" one of my test databases (not only take it offline) and I was able to do a tail-log backup WITH CONTINUE_AFTER_ERROR and also to restore the database to that transaction log backup.

    Definitely I learned something today. Good question!

  • Koen Verbeeck

    SSC Guru

    Points: 258985

    Nice question, thanks.

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Ed Wagner

    SSC Guru

    Points: 286985

  • This was removed by the editor as SPAM

  • sestell1

    SSChampion

    Points: 10230

    Paul Randal has a blog post about doing a tail backup of the log for a database that can't/won't come on-line.

    He does a bit fo shuffling to back it up using NO_TRUNCATE.

    http://www.sqlskills.com/blogs/paul/disaster-recovery-101-backing-up-the-tail-of-the-log/

    Is WITH CONTINUE_AFTER_ERROR new with 2012 and avoid some of the shuffling he needed to to?

  • SQLRNNR

    SSC Guru

    Points: 281252

    Straight up question. It is nice to have questions about important topics such as recovery. Too many people will forget to perform that very essential first step.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Raghavendra Mudugal

    SSChampion

    Points: 10658

    raulggonzalez (7/18/2014)


    twin.devil (7/18/2014)


    Tail log backup WITH CONTINUE_AFTER_ERROR works only if the database goes offline in case during the start up of the database is fail to come online due to some reasons or damaged due to some reason, in case if we did purpose fully then that will not work (i,e the database didnt have any issues at all)

    True, now I took the time to manually "corrupt" one of my test databases (not only take it offline) and I was able to do a tail-log backup WITH CONTINUE_AFTER_ERROR and also to restore the database to that transaction log backup.

    Definitely I learned something today. Good question!

    +100000000

    Thank you, raul and twin;

    your script and the twin's extended explanation is really really really ... really extraordinary information in this section.

    (had a vague idea..... after reading the question and then the raul's script- I started to think like this "server putting database offline" and/or "putting database manually offline"..... and then I jumped "well offline is an offline" ended with a absolute wrong conclusion, thank you twin for really good insight on this. this makes so much sense to me now...)

    To author: very interesting question, thank you for the post.

    ww; Raghu
    --
    The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.

  • John Hanrahan

    Hall of Fame

    Points: 3825

    For me this was an UBER important question. I have never had to do this but am in charge of DR at our company for the databases.

  • SqlMel

    SSCrazy

    Points: 2891

    Good question.

    Thanks!

    ---------------
    Mel. 😎

Viewing 15 posts - 1 through 15 (of 20 total)

You must be logged in to reply to this topic. Login to reply