How to retrieve databases in rescue mode
Objective
With rescue mode, you can always access your data, even if the server's OS or the software hosted on the server is no longer working.
This tutorial explains how to access a system in rescue mode and retrieve database files.
Requirements
- A dedicated server, a VPS or a Public Cloud instance in your OVHcloud account (excluding Windows systems)
- Access to the OVHcloud Control Panel
OVHcloud is providing you with services for which you are responsible, with regard to their configuration and management. It is therefore your responsibility to ensure that they function correctly.
This tutorial is designed to assist you in common tasks as much as possible. Nevertheless, we recommend that you contact a specialist service provider or reach out to our community if you face difficulties or doubts concerning the administration, usage or implementation of services on a server.
Instructions
Rebooting your server into rescue mode
Follow the respective guide to put your OVHcloud service into rescue mode:
Follow the instructions in this section for a VPS or a Public Cloud instance. Skip to the subsequent section for a dedicated server.
Accessing your data on a VPS or a Public Cloud instance
First we need to identify the mount point containing the / of our system.
To do this, you can use the commands lsblk and fdisk -l.
- lsblk example output:
- fdisk -l example output:
The following code sections are for the purpose of illustration only, based on the example output above. You will need to adjust the instructions according to your actual configuration by replacing the values in the commands with your disk and volume identifiers.
In this example the primary disk (10 GB) is named "sdb". Our data in / is therefore located on the partition /dev/sdb1. (Whereas "sda" is the rescue mode disk and "sda1" is the primary rescue partition mounted on /.)
We mount the system partition in the folder /mnt and then verify its content:
In order to launch services on the system from rescue mode, you will need to mount these partitions as well:
Continue with the database retrieval section below.
Accessing your data on a dedicated server (software RAID configuration)
First we need to identify the mount point containing the / of our system.
To do this, you can use the commands lsblk and fdisk -l.
Example output:
The following code sections are for the purpose of illustration only, based on the example output above. You will need to adjust the instructions according to your actual configuration by replacing the values in the commands with your disk and volume identifiers.
In this example, our data in / is located on the volume /dev/md3.
We mount the system partition in the folder /mnt and then verify its content:
In order to launch services on the system from rescue mode, you will need to mount these partitions as well:
Retrieving the databases
With all the necessary partitions mounted, we need to be able to execute commands on the actual system. You can do this by using the chroot command:
From this point on, all commands that you enter will be applied to your system instead of the temporary rescue mode environment.
We can now start the mysql service:
Use the command mysqldump to save the database as a file:
In this case, the mysql user logging in to the database is root. The option -p allows you to enter the password of root and the recovered database is named scarif.
The database file is then saved into the /home directory under the name dump.sql.
You can also back up all databases at once:
Listing the contents of /home shows both database files created by the previous commands:
In case of corrupted tables, this command can be used for repair:
From the /home folder, you can now send your backup files to a remote server. This example uses the file transfer utility scp:
Go further
Join our community of users.