The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

how to restore sql from slave disk

Discussion in 'Database Discussions' started by Norcomp, Jan 7, 2006.

  1. Norcomp

    Norcomp Member

    Joined:
    Jul 20, 2003
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    I had to change disk because of sector problem and got a new disk. old disk is mount as slave so i could copy the files from old on.
    Question is how can i restore/make a sql dump of that sql db to customers from old disk when i not can do that from phpmyadmin or cpanel when i only can list the file like this
    -rw-rw---- 1 mysql mysql 1024 Jan 6 16:22 ibf_statistics.MYI
    -rw-rw---- 1 mysql mysql 8736 Jan 6 16:21 ibf_subscription_currency.frm
    -rw-rw---- 1 mysql mysql 0 Jan 6 16:21 ibf_subscription_currency.MYD
    -rw-rw---- 1 mysql mysql 1024 Jan 6 16:21 ibf_subscription_currency.MYI
    -rw-rw---- 1 mysql mysql 8826 Jan 6 16:21 ibf_subscription_logs.frm
    etc.
     
  2. chirpy

    chirpy Well-Known Member

    Joined:
    Jun 15, 2002
    Messages:
    13,475
    Likes Received:
    20
    Trophy Points:
    38
    Location:
    Go on, have a guess
    So long as those files have not been created/updated already in the live location, you should be able to do the following:

    service chkservd stop
    service mysql stop
    cd /var/lib
    mv mysql mysql.orig
    cp -avf /yourslavedisk/var/lib/mysql ./
    service mysql start
    service chkservd start


    If that breaks things you can stop mysql again and mv mysql out of the way again and mv mysql.orig back to mysql.
     
  3. soundguy

    soundguy Well-Known Member
    PartnerNOC

    Joined:
    Oct 29, 2003
    Messages:
    52
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    seattle
    I know this is a very old post, but it really saved my backside today when I had a primary drive crash and had to restore from backups. To my horror, I discovered that cPanel backup had somehow been switched to "mysql dir only" and the restoration process failed to generate the customer's OsCommerce database, resulting in thousands of unhappy customers and one VERY unhappy client. Fortunately, my research brought me to this thread. Thanks Chirpy. You're my hero :D

    I'd like to add a couple of lines though because the original doesn't take file ownership into account and also doesn't mention that cPanel sometimes generates TWO MySQL backup directories with very different information within - one with and one without a trailing underscore. In my situation, the directory with the underscore was the correct one. This assumes that your backups have the same path as mine and you are restoring from daily backups.

    service chkservd stop
    service mysql stop
    cd /var/lib
    mv mysql mysql.orig
    cp -avf /backup/cpbackup/daily/dirs/_var_lib_mysql_ mysql
    chown -R mysql:mysql mysql # this is where the magic happens
    service mysql start
    service chkservd start

    The file ownership issue caused me a half hour of spinning my wheels until I noticed it. Hopefully this post will save the next guy a few minutes :)
     
Loading...

Share This Page