I accidently imported an empty database backup file into the same database, using mysql-workbench. Is there any way to undo this and get the data back? The backup available is 4 months old which is too old to restore, any ideas?
This question appears to be off-topic. The users who voted to close gave this specific reason:
- "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – mustaccio, LowlyDBA, MDCCL
No, you can't. You have overwritten the database so your best course of action is to restore from the latest backup. If that is 4 months old, that's it, you lost 4 months of data.
You should take backups more often and also before any critical operation (like this one) that has the chance of destroying data if it goes wrong.
Before you go and overwrite again the database by restoring the 4-months old backup - and depending on the value of the data you lost - you can take this action:
- stop the database instance/service, immediately.
- make sure it doesn't restart (MySQL is often installed with a "watch-dog" that restarts it when it fails).
- take a complete OS-level backup of the mysql directory or the whole file system, to another, external disk / file-system.
You may be able to find (very expensive) companies/services that may be able to recover some of the data you lost.
It might even be better - if you go the expensive route - to keep this machine (completely shut down or stop all services but not shut down or do whatever these consultants tell you to follow; contact them before you take any severe action) and restore the backup in a separate machine, so you have the best chances of recovering whatever data you can from the existing machine/installation.