MySQL Forums
Forum List  »  Backup

Re: mysqldump - how to restore without overwriting new records?
Posted by: Rick James
Date: January 26, 2012 02:59PM

Not easily.

First, let's determine the scope of the problem.
Are there UPDATEs?
Are there DELETEs, plus re-INSERTs?
INSERT ... ON DUPLICATE KEY UPDATE?
If any of those, do you want the old value or the new?

Assuming nothing but INSERT and DELETE, and they never overlap, then

Plan A:
* Check for (and remove) DROP TABLE in the dump.
* Check for (and add) IGNORE to the INSERT statements in the dump.
Then reload.

Plan B:
1. Load the dump into a different database(s).
2. Use various SQL statements to copy over the desired rows.
3. Drop the new database(s).
The query might be something like
INSERT INTO real SELECT ... FROM dump LEFT JOIN real ON dump.id = real.id WHERE real.id IS NULL;

Options: ReplyQuote


Subject
Views
Written By
Posted
Re: mysqldump - how to restore without overwriting new records?
5469
January 26, 2012 02:59PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.