Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Tuesday, November 17, 2009

Recovering from "database cleaning" - mySQL - innoDB

OR: "How to cover your ass when your belt snaps and you forgot to wear your braces.  (Proof of the wear clean underwear rule.)
OR: When work is a little like duck hunting with Dick Cheney.


Today we had a bit of a scare. Someone decided to "clean up the databases".

Who needs to worry about this:

When you can just do it yourself :
mysql> drop foo;
"oh... you mean that 'foo' was in use ?  ? I was sure  it was useless." 
Rule 1: Always backup  before you delete. 
Always. Always. Always.

Memorize this: # mysqldump -u username -ppassword database_name > FILE.sql 

Thankfully the db was for an app with only a small amount of data.  So though a loss would be sad, it would not be catastrophic.  The other saving grace is that the app involves  undergrad students, not say, Vice Presidents, or Dept heads.  This is good as undergrad students are slightly above janitors in the pecking order.

I was training a new person when I got pulled in to the issue. So she got to experience the heavy breathing and waving of hands. Now that she has been exposed to the dark underbelly of our procedures on her first day, If she decides to stay, at least she has seen the worst.

This brings us to:
Rule 2: Backups are nice, but Restores are nicer.


It turns out that the restore plan was to copy all the files back in to place in the database directory in question.  We kept restoring the files from backups, and guess what, they all had the original creation date still. No data! We questioned our backups. But something seemed fishy to me, so I poked around and noticed that the other database directories had additional files,  e.g. .myi and .myd files - and this directory had only .frm files.  
From this I discovered -(thanks Google: )

That it was an innodb database not a myisam db, and so the data was stored elsewhere (by default in an ibdata1 file, in the directory one level up)


So I was pretty much able to restore the ibdata file and not lose anything. And Someone was pretty happy.


Wednesday, October 21, 2009

Desktop Fedora -> Ubuntu - Thunderbird problem

After changing my desktop from Fedora to Ubuntu my thunderbird profile disappeared -
When I started up thunderbird, instead of seeing all my old accounts, I saw:

No! I don't want to freakin' import 3 mail accounts, and my assorted local folders! Guess again!

We use nfs to mount /home directories, so it should JUST WORK. Right....

I looked in my .thunderbird directory - and there was my sweet little old profile, just like always:


xxl@foo:~$ ls -l .thunderbird   

total 11
drwx------ 7 xxl dept  37 2009-10-21 16:55 1bn7kwbx.default   
-rw-r----- 1 xxl dept 335 2009-10-21 14:42 appreg                    
-rw-r----- 1 xxl dept  94 2008-04-07 11:33 profiles.ini      

But whoa.. what's this?

drwx------  8 xxl dept     10 2009-03-17 13:10 .mozilla
drwx------  3 xxl dept      4 2009-10-21 17:23 .mozilla-thunderbird
drwxr-xr-x  2 xxl dept      8 2008-11-07 11:14 .mplayer

...

Ok then, take this you impostor!
xxl@foo:~$ rm -r .mozilla-thunderbird
xxl@foo:~$ mv .thunderbird/ .mozilla-thunderbird

And just in case I might want to use a fedora desktop again

xxl@foo:~$ ln -s .mozilla-thunderbird/ .thunderbird   

Ok, That's better.

 Kind of.Except for the hours of email to get to.

See forums.mozillazine.org
for a discussion.