If you get locked out of your VPS and cannot access Port 80 (HTTP) or Port 22 (SSH), OVH’s rescue mode helps you recover the files and mysql data
OVH is one of my favourite VPS providers. For a paltry sum of $3.49 per month, OVH offers a VPS which has the following specifications:
• OpenStack KVM
• 1 vCore
• 2.4 GHz
• 2 GB RAM
• 10 GB SSD
• Local RAID 10
The VPS is fast and responsive.
The price is also cheap. A VPS from Linode with 2 GB RAM costs $10 per month though it offers 30 GB of storage as against the paltry 10 GB of storage offered by OVH.
OVH’s SSD 2 VPS offers 20GB SSD with 4GB RAM for $6.99 per month which is still less than that charged by Linode.
Centminmod upgrade/ update blocks Port 80 and other ports
Centminmod is one of my favourite auto installers (the other is EasyEngine). Just one click and Centminmod provides a fully functional VPS with Php, MySQL and Nginx pre-loaded.
Centminmod and EasyEngine are the best and most convenient methods of setting up a VPS with Nginx loaded in it.
Centminmod offers the option of upgrading/ updating the core components of Nginx, PHP etc.
However, I got an unpleasant surprise when I chose the upgrade option and found that my VPS was not accessible at all. The web pages were not opening nor was I able to access the VPS through SSH using putty.
The VPS was, however, responding to pings which showed that it was powered on.
A check at yougetsignal revealed that all the ports were closed.
I tried rebooting the VPS multiple types but it did not help.
OVH Rescue Mode
The OVH control panel offers the option to boot the VPS in rescue mode.
The VPS vps354….ovh.net will reboot in rescue mode (estimated time 3 minutes).
Some actions are not available in rescue mode. To restore functions, you must restore the local boot by clicking “Restart your VPS”
After a few minutes, you will receive an email containing the following information:
OVH HOSTING INC. – http://www.ovh.com
1801 ave. McGill College | Suite 800
Montréal (Québec) H3A 2N4
Your VPS has booted into rescue mode, meaning that a Linux OS has been launched on your VPS. The reboot is not related to your system, which is correctly installed:
– Your VPS’s tree structure has mounted into ‘/mnt’.
You can log in to your VPS (51.254……..) via SSH with the following parameters:
– username: root
– password: 210JVd8o
You can now carry out the necessary maintenance to restore your VPS. For example, you can:
– check and, if required, deactivate your firewall
– perform a backup or data recovery
– check and update your network configuration files
If you think that you have identified the cause of the problem and wish to reboot your VPS normally, you must configure the netboot of your VPS on the hard disk (normal mode).
You will find additional information in our guide:
Now, log into the VPS using the username and password set out in the email.
Find the path where the files are kept. Obviously, it will be the partition where the most space is occupied.
login as: root email@example.com.....'s password: root@rescue-pro:~# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 4.7G 1.3G 3.2G 29% / udev 10M 0 10M 0% /dev tmpfs 393M 5.3M 388M 2% /run tmpfs 982M 0 982M 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 982M 0 982M 0% /sys/fs/cgroup /dev/sdb1 9.8G 8.0G 1.3G 87% /mnt/sdb1
Navigate to the partition you want:
See all the files in it
In Centminmod, the website files are in the /home folder
(In Easyengine, they are in the /var/www folder)
Once you spot the files you want, take a backup with the command
tar -cpzf backup_30032017.tar.gz *
This command will make a tar file of all the contents in the folder.
Normally, to take a backup of the Mysql data, one uses the command
mysqldump --all-databases -uuser -ppassword >database30032017.sql
However, this command will not work in the rescue mode because the mysql service is not working and is not accessible.
Fortunately, we have access to the raw mysql database files (more details are available at jb.demonte.fr)
Go to the /var/lib/mysql folder. Here, you will find all the database files bearing the names of the respective databases.
Take a backup of these files with the command
tar -cpzf mysql-backup-30032017.tar.gz *
tar -cvzf mysql-backup-30032017.tar.gz var/lib/mysql
Now, we have to bear in mind that because Centminmod and Easyengine use MariaDB as the MySQL engine, a normal MySQL should be avoided because there will be errors due to some incompatibilities of the two mysql engines.
So, set up another VPS with Centminmod.
In the rescue mode, wget will not work. So we have to use SCP (Secure copy).
Go to the new VPS and pull in the backup of the files and mysql data from the VPS in rescue mode using the command
scp root@ IP-address-of-rescued-VPS:/mnt/sdb1/home/nginx/domains/name-of-backupfile-.tar.gz /home/nginx/domains/-path-of-new-VPS
Unzip the website files in the required location (/home/nginx/domains/) with the command:
tar -xzf backup-30032017.tar.gz
With regard to the mysql backup data files, go to the /var/lib/mysql folder and deposit the files in that folder.
All the files in the /var/lib/mysql folder must be owned by MySql
This is achieved by executing the following command when inside the folder:
chown mysql:mysql –R *
chown -R mysql:mysql /var/lib/mysql/
If you have set up the new VPS with the same password as that in the rescued one, there is no problem. Otherwise change the root password using the command:
mysql -u root -p
update user set password=PASSWORD('your_new_password') where User='root';
With this, the website files and mysql data is restored to the same condition in which it before you got locked out.
P.S: When you get access to the rescued VPS, try disabling the CSF, IP Tables (if Centos 6) or FirewallD (if Centos 7). Also try manually opening ports 80, 22 etc. If this works, all the trouble to take a backup and move to another VPS etc can be avoided.