Export DB in rescue mode with mounted HDD

napok

Verified User
Joined
Feb 23, 2010
Messages
13
Hello,

Because something happened to my server, I'm currently only able to boot into rescue mode.

I mounted the HDD so I can make a backup. However, I have absolutely no clue on how to backup the database's without the use of phpmyadmin.

Could someone tell me how to do this? Is it even possible?

Thanks in advance.
 
you can use mysql command-line and mysqldump - however if you haven't booted into your server with mysql running - you are down to the raw files. unfortunately if you have innodb tables, copying the database tables binary files will not work cleanly (only for myisam etc).

checkout:

http://dev.mysql.com/doc/refman/5.1/en/backup-methods.html

and Google for restoring mysql database from binary log files and tables.
 
Thanks for the quick answer.

MySQL is not running indeed. I'm limited to only a few commands and I'm not sure what kind of tables I have.

I'll have a look at the link you provided and will report back here with the result.
 
have you ever done an admin_backup or run backups via the DA interface?

if you have done admin_backups, you can restore the databases via these files too.
 
No, unfortunately I didn't. Server has a RAID config, so I thought I wouldn't need it.
 
hmm, well next time ensure you run the admin_backups and set them as a cron job daily ...

anyway you're here and we'll see what we can do to help:

I've done restores from files before - and it's a pain, and time-consuming, especially if you have INNODB tables.

MYISAM tables:

* The FRM file is the table definition.
* The MYD file is the where the actual data is stored.
* The MYI file is the where the index created on the table are stored.

For those files, you can just copy them into your new mysql folder (ensure that mysql service is stopped), restart mysql after copying and then go to repair corrupt databases and tables using mysql commandlines.

As for INNODB, I've also managed to get them going again - but as I said before it was a complete pain.InnoDB stores its tables and indexes in a single tablespace *, which by default consist of the 3 files ibdata1, ib_logfile0, and ib_logfile1. for restoring a database, you would also need those files. * per-table tablespaces are possible, but not default.
 
Do you have any idea where to find these DB files? I can not use the search commands. Besides that I guess I still have to get MySQL running first, so I can use the tool they mention in the manual.
 
/usr/local/mysql/data/

try copying the files over first on your new setup, you may be surprised it could be as simple as that!

It's also probably worth working out why you can only boot in rescue mode ... it could be fixable!
 
Last edited:
There's no mysql folder inside /usr/local. There's a directadmin folder, but with no mysql folder inside.
I searched everywhere and can't find the mysql folder.
 
check your my.cnf file for the datadir

/var/lib/mysql is the other place people use.
 
It was /var/lib/mysql indeed.

Could you tell me what files I have to backup? Do I only have to backup folders with DB names? Or do I have to backup all files inside that mysql dir?

Thanks for your patience!
 
i would copy the whole /var/lib/mysql/ folder

oh, and a word of warning, make sure your new box has the same version of mysql (this will help with any twiggly problems).

take a copy of the folder on your new server too (just incase you need to put it back)

when you copy them over to the new server MAKE SURE MYSQL IS NOT RUNNING! Check ps -waux and killall mysql instances and stop the service.

copy the files over

start mysqld - watch all your log files (/var/log/messages etc)
(might also be worth turning on mysql logging if it isn't) /var/log/mysql.log
 
I know it goes without saying, but I thought quoting it right the horse's mouth, so to speak, probably wouldn't be a bad idea.

Here's what Seagate (seagate.com) has to say about RAID as a backup strategy:
Does a RAID configuration mean you don’t have to backup?

RAID (specifically RAID 1) is a method of using two internal hard drives that mirror one another. So, in theory, if one of them fails the other keeps going.

We say in theory, because RAID has been known to react differently in real life than it does on paper. There have been reliability issues with RAID configurations—failures, data corruption, etc. And with both drives in the same location, whatever might corrupt one drive could easily get both—a power surge, fire, or flood.

So, in our opinion, using RAID is not a substitute for performing regular backups to an external drive.
 
I wish I had seen this thread earlier. After booting into rescue mode and after the hard drive is mounted you can chroot to your system and then run everything you need including mysql, directadmin, apache, phpmyadmin. You can run the entire system that way but you have to start everything manually. I once ran a system like that for several hours while I finished getting my beauty sleep.
 
Back
Top