Skip to main content

Restore databases from dead server

Answered

Comments

10 comments

  • ffeingol

    Are you able to get MySQL started through rescue and create backups?  That would be the safest way to copy them over.

    0
  • HaNi Ghaith

    I was able to move a copy of the contents of the mysql folder with the following command to the remote server.

    scp -r /mnt/var/lib/mysql/ root@ip:/var/lib/mysql


    But how can I restore it so that it is linked correctly.
    I tried moving the contents of the folders to the /var/lib/mysql path on the new server, but the databases or tables did not appear in phpmyadmin.
    I created a database from cpanel and then attached all the files inside its folder in its path
    For example:
    /var/lib/mysql/cpuser-dbname
    However the tables were not reflected in phpmyadmin

     

     

    0
  • Hi,

     

    It would typically be easier to restore the MySQL data by creating full account backups from the old server, then restoring them. Manually copying the MySQL data directory does not restore the cPanel user's database map/grants. We have a guide below aimed to help with recovering from a dead server:

    Full Disaster Recovery

    0
  • HaNi Ghaith

    Is there no other way to restore databases without going back from the beginning?
    I now have all the database files. All I need is a way to compile them into SQL files without problems in order to import them into the new server.

    0
  • ffeingol

    If you copied the files from the old server to /var/lib/mysql and mysql started, then more than likely the databases are there.  You can check this from WHM PHPMyAdmin or from ssh just run "mysqlshow" and see if there are any databases.

    The issue as William Del Piero pointed out is by recovering this way the databases are not mapped to cPanel accounts, so they are not going to show up in cPanel.

    0
  • HaNi Ghaith

    Thanks for your response
    I did this on a private server that only has mysql-server
    Earlier, I tried with another clean server. I installed phpmyadmin. There, the tables appeared, but they were empty

    I followed this guide
    https://askubuntu.com/questions/964417/is-it-possible-to-restore-a-mysql-database-from-the-var-lib-mysql-database-fold
    I will now try to see if the databases exist using the mysqlshow command

    0
  • HaNi Ghaith

    Unfortunately, none of the databases exist

    root@ubuntu-8gb-hel1-1:~# mysqlshow
    +--------------------+
    |     Databases      |
    +--------------------+
    | information_schema |
    | mysql              |
    | performance_schema |
    | sys                |
    +--------------------+

    Although all database folders are located in /var/lib/mysql

     

    0
  • ffeingol

    That post is 6 years old.  With things move to innodb trying to copy the /var/lib/msyql folder is a lot mroe difficult.  Again, is it not possible to start MySQL on the old/recovered server?

    0
  • HaNi Ghaith

    I've tried the documentation for the current host as well
    https://support.hostinger.com/en/articles/4635603-how-to-recover-mysql-databases-from-mysql-data-files-in-vps

    The old server is connected to the hard disk through mount via the rescue system, is there a way to synchronize the services and start mysql?

    If there was a way, it would be easy to make SQL copies of the databases and transfer them to the new server.

    0
  • HaNi Ghaith

    I tried to run mysql by executing the following commands.


    mount -o bind /dev /mnt/dev mount -t proc proc /mnt/proc mount -t sysfs sys /mnt/sys chroot /mnt

    But I am unable to access the system
    [root@host ~]# chroot /mnt/
    chroot: failed to run command ‘/bin/bash’: No such file or directory
    0

Please sign in to leave a comment.