In my Django web application, I had a user delete a few records that seemed safe to delete. Turns out they were connected via ForeignKeyField
fields to a fairly large set of other, highly important records. I now know that I can manage how deletes are handled, but this knowledge comes after this event occurred.
My main question is: is there an easy way to fix this or is it simply a matter of meticulously restoring each record, one by one, from backups?
More Details
Every night, I do a backup of the MySQL database using mysqldump
. So I have a backup of all the data the day before this happened. The problem is that these backup files will restore a database in full. Given that we didn't notice the problem for a week or so, restoring the whole database I think is not an option since it would override other legitimate changes from the day the deletes happened to now.
I think my only option is to manually, one by one, pick out the records from the MySQL dump file, and manually INSERT
them back into the MySQL DB. This feels like a bad idea since it's heavily prone to human error - my own typing.
Is this the only way or is there a better way?!