We have a MySQL backup. Did some changes on our database and some data was lost. In the mean time new records were added.
We have to restore the mysql backup over our latest data.
Some of the tables have auto increment columns which means that we will end up with the same primary key but different values in some tables. The majority of the tables are from a many-to-many or one-to-many relationships.
What is the best approach to resync the same schema between the backup and the current data?
Best Answer
LEFT JOINs
one way, then the other way, to see what was deleted/new.JOIN
to see if the rows that exist in both are the same; fix if necessary.DELETE
to get rid of the the appropriate rows.INSERT...SELECT..LEFT JOIN
to copy the missing rows in