Recovery using .ldf file in sql server 2005

  • Hi

    I need to recover data from .LDF file whereas I have lost my .MDF file. My database was in Full Recovery Mode, I have full backup of a day back, but no transactional backup. Having full backup of Thursday, changes made in database on Friday. I dont have any backup of Friday, I need to recover till Friday. How can I overcome this problem, I have only .ldf file, please give me some solutions.

    Thanks in advance.

  • Full recovery and no log backups?

    Was the log getting manually truncated? (backup log .. truncate only)?

    Is the database still attached to SQL? (I know the mdf is missing). Is it still listed if you query sys.databases?

    p.s. How do you lose an mdf file?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • One of my colleague used to truncate manually, database is still attached to SQL and yes, it is still listed if I fire select * from sys.databases.

  • If the log was manually truncated since the last full backup, then there is no way to recover anything from the log as the log chain has been broken by the manual truncate.

    Please ask your colleague when was the last time that he truncated the log.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • The last time he truncated the log on Friday at 8:00PM, I understand I can not go back. Is there any chance of data recovery of 8:00PM onwards?

  • There is no chance of recovering anything. By truncating the log you discarded log records and told SQL that you were not interested in retaining log records any further. Additionally, a log chain has to be intact to recover. By discarding log records you broke the log chain and hence, even if the log records post that 8pm were retained (which they weren't), they'd be useless for recovery because of the missing log records.

    The best you can do at this point is to restore to the Thursday backup. All data from friday has been lost because of the log truncations. I suggest in future you reconsider your backup and log maintenance strategies. This may be worth a read - Managing Transaction Logs[/url]

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thanks Gail for your all replies.

  • Sorry, my colleague provided me the wrong informations, he never truncated the log file. .LDF file never got truncated. Is there any chance of recovery ?

  • Maybe, as long as he's completely sure that there was no truncation. (by him or anyone else or in a scheduled job)

    Backup log <database name> to disk='<location for log backup>' with no_truncate

    If it gives any errors, post them.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Command run successfully, do I need to restore full backup then all log backups ?

    Following message appeared on running the query provided by you.

    Processed 5 pages for database 'dr', file 'DR_log' on file 1.

    BACKUP LOG successfully processed 5 pages in 0.089 seconds (0.431 MB/sec).

  • Nevermind, Gail responded before I could find the reference below.

    You might, might, be able to attempt a tail log backup of the database. Check this out: http://msdn.microsoft.com/en-us/library/ms179314.aspx.

    Other than that, not sure if you will be able to recover since the last full backup.

  • beejug1983 (6/11/2010)


    Command run successfully, do I need to restore full backup then all log backups ?

    Yes, restore the full backup from thursday WITH NORECOVERY, then restore all log backups (I assume just this one that you took now) in sequence. All but the last one should have the WITH NORECOVERY option.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Thanks Gail, your efforts saved me from big problem. Thank you very much.

  • May I suggest that you start running scheduled T-LOG backups? This will help manage the size of the transaction log and make database recovery a bit easier.

  • Thanks for your reply.

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

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