0

I have two MySQL databases on the same production machine, lets call them: mainDB and testDB. Every night, this production machine does a database dump as a backup. Last night I was asked to see if I could restore a single record from a few months ago. So, I merrily restored some old backups to the testDB being exceedingly careful to NOT restore to mainDB. I did the restore to testDB, poked around, did some stuff, and went to bed.

I wake this morning to my office calling, freaking out that all the data on the production machine is old data - months old. I look and, sure enough, it's all old. In fact, it looks exactly like the old data I was looking at on testDB. I frantikly open up an SSH window and starting hitting the "up" arrow to see each command I ran, thinking I ran the restore of the backups to the production mainDB. However, I did not. The exact command I ran was:

mysql -u garfonzo -p testBD < backupFile.sql

That's it. I didn't do any other commands to do a restore/backup. However, somehow the mainDB also has this data. It's like the two are connected somehow (which I haven't set anything up to connect them).

Do you guys know of anyway that this could have happened? Is there some investigative something I could do to determine how this happened? I mean, I'm looking at the few commands I ran last night, but nothing shows up as any kind of hint that I did something in error.

pulling out my hair

Any thoughts?

**EDIT

I should mention that, after I went to bed the nightly backup ran. This backup, to my horror, backed up the old data. So not only has the production machine somehow picked up old data, but my backup is also of old data. So I have to restore from two days ago meaning they lost all their work from yesterday.

4

1 回答 1

0

As per Stijn's comment to my question, the answer is due to my backup dumpfile containing USE mainDB in the first line. Thus, even though I tried restoring to a testDB, the restore was done to the main DB.

Perhaps this will help someone else in the future.

于 2013-09-27T14:48:36.447 回答