Recovering from a DB Fuckup
I have a DB server and a mirror server. While testing some code I set the new data to go to the mirror server.
This meant the main DB was missing data and queries to that machine returned the wring data.
Why? I was also doing a speed test and forgot to change the dbhost back when I was done.
I needed to get the new data from the mirror and insert it back into the proper DB.
To dump the data:
mysqldump --insert-ignore --no-create-info -h maria.local tlogger -p \ --tables data --where="datetime > '2024-02-19 00:00:00'" > tlogger_data.sql
Since it was a day's worth of data I limitied the select with the where clause.
I didn't want the DROP and CREATE but I did want INSERT IGNORE data in case there was an overlap and the data already existed.
Then a simple;
mysql -h maria.local tlogger -p < tlogger_data.sql
inserted the data.
Of course the mirroring will now try to insert that into the mirror where the data came from, but this caused no issues.
Last changed: 21. February, 2024 at 11:35
Back to Overview