Here is the situation: your system is down, no way to access it.
You need to restart it in the rescue mode of your hosting provider.
Once the rescue mode activated, your hard drive is plugged and available as a simple storage device on a virtual machine you got the credential by mail, admin or any other way.
So, you access it using ssh with these credentials:
List the devices available and locate it (testing mount / umount)
Once located, mount it:
mkdir /mnt/sda2/ mount /dev/sda2/ /mnt/sda2/
Backup your www path (and other config files you should need)
cd /mnt/sda2/ tar -cvzf www.tar.gz var/www/ tar -cvzf php.tar.gz etc/php5/apache2/ tar -cvzf apache.tar.gz etc/apache2/sites-enabled/ ...
MySQL is off, you need to backup the database raw files, no way to dump it using mysqldump.
So, first, locate the MySQL storage file:
grep datadir etc/mysql/my.cnf datadir = /var/lib/mysql
Backup the files:
tar -cvzf mysql.tar.gz var/lib/mysql
Using SCP, download your files from your local machine (or upload to…):
mkdir backup_ovh cd backup_ovh/ scp user@your_ip:/mnt/sda2/*.tar.gz .
Now, two solutions, either you want to use the file system as it because you’re on your new machine or you want to mount the files in order to dump it.
I’ll descrive the second one because the first one is a part of the second one.
Setup the database files on your local mysql:
tar -xvzf mysql.tar.gz
Because of my compression path, the extraction path is ~/backup_ovh/var/lib/mysql/
Change the file owner to MySQL:
sudo chown -R mysql:mysql ~/backup_ovh/var/lib/mysql/
sudo /etc/init.d/mysql stop
Update your local path:
sudo vi /etc/mysql/my.cnf
Update datadir with the path of ~/backup_ovh/var/lib/mysql/
If you restart MySQL now (don’t! not needed), you should get the error:
ERROR 1045 (28000): Access denied for user ‘debian-sys-maint’@’localhost’ (using password: YES)
The debian-sys-maint password is stored in /etc/mysql/debian.cnf
sudo cat /etc/mysql/debian.cnf
Copy it and start mysql as root or skipping security if you don’t have the root password using:
/usr/bin/mysqld_safe --skip-grant-tables &
Update its password:
use mysql update user set password=PASSWORD("the password from /etc/mysql/debian.cnf") WHERE User='debian-sys-maint';
Update the root password if you’ve lost it to with:
update user set password=PASSWORD("your root password") WHERE User='root';
Restart MySQL by exiting the foreground task
fg ^C sudo /etc/init.d/mysql restart
Dump your database or simply use it.
mysqldump -uroot -p --all-databases --add-drop-table > dump.sql
Now, you’ve your files and your database dump, you can now re-install it on a fresh system.