Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Let's say I backup a database like this:

mysqldump -u usrname -p pass dbname > dbbackup.sql 

Then I delete a pile of rows from dbname.

Then new rows are inserted into dbname. However, I decide I want to 'undelete' the rows I deleted. How can I restore the dbbackup without overwriting the new rows?

share|improve this question

Best thing you can do is restore the backup to a new database, and then run queries (which will depend on the application(s) using the tables) to identify the rows you want and transfer this data across.

Remember to keep taking backups as you go through this process to limit possible data loss, and make sure the backups aren't overwriting each other as you go.

pt-table-sync could well be of help to you, but you'll need to read up on it thoroughly, specifically the parts about Bi-directional syncing. I haven't used it except to sync master/slave but from what I can see it could well work in your situation (if you restore your backup to another database).

Just remember, take backups before you do any step. Even the restore of the backup to another name. Nothing is going to ruin your day faster than restoring over the top of your current DB.

share|improve this answer

If that is a feature you requrire it will take require a datatbase schema specifically designed to support that.

Just doing that on any random database is almost certainly going to result in a serious mess.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.