Restore databases from dead server
AnsweredHello,
One of my server is dead and I were able to access the files and databases through the rescue system.
I have now started migrating all accounts files to the new server.
I also started migrating a copy of the database folder
/mnt/home/var/lib/mysql
To the new server, but I cannot find the SQL files to transfer, for Example user-dbname.sql
Unfortunately, I don't have any backup copies
Can you tell me if it is possible to get the SQL file from the database?
If this is not possible, what should we do to use the databases in the /home/var/lib/mysql folder so that they work the sites again on the new server?
Best Regards.
-
Are you able to get MySQL started through rescue and create backups? That would be the safest way to copy them over.
0 -
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 phpmyadmin0 -
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:
0 -
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 -
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 -
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 emptyI 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 command0 -
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 -
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 -
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-vpsThe 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 -
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 directory0
Please sign in to leave a comment.
Comments
10 comments