Does restoring a database overwrite transaction logs?

Posted on

Question :

I accidentally restored an sql server database from a backup file and lost all my previous data. I did not have any backup but I read that some third party software (like apexSQL) can retrieve some data by reading the transaction logs. However, if restoring the database has also overwritten the transaction log file, this operation is pointless.

So my question is: does restoring a database from a backup file also overwrite the transaction logs or just append to it.

Answer :

During a Restore of an existing database, the transaction log will be completely overwritten. If data you needed to retrieve was written after the last known good backup (Full or Transaction) and you’ve already restored the database then the log is overwritten and the data is lost from an SQL Server perspective.

If a Server or SAN backup is taken, it could be possible to recover a copy of your original .mdf and .ldf file from here although this is generally frowned upon
For real recovery you should only use native SQL Server backups but if this is the only option to recover a production database, then you can’t be faulted for that but it is not a good solution in its own right. But I would attach as a separate database and run CHECKDBs on it to make sure there is no corruption first.

Leave a Reply

Your email address will not be published. Required fields are marked *