How do I revert my DV to default?


  • Applies to: DV 4.0
    • Difficulty: Easy
    • Time Needed: 20
    • Tools Required: SSH, root access, developer tools
  • Applies to: DV
    • Difficulty: Easy
    • Time Needed: 20
    • Tools Required: SSH, root access, developer tools
  • Applies to: DV Developer
    • Difficulty: Easy
    • Time Needed: 20
    • Tools Required: SSH, root access, developer tools

Overview

This article outlines the process of reinstalling your DV server to bring it back to a default state. The DV product includes the functionality to do this from within your Plesk Control Panel. You can also reinstall from the Advanced Recovery Tools section of your Account Center's DV Control Panel. We will cover both methods in this article.

Before you start

This article has the following dependencies:

  • Whenever installing third-party software, please consult the official documentation. (mt) Media Temple does not support the installation and configuration of software not installed at time of service activation. Please consult our DV Scope of Support page for further explanation.
  • The domain example.com is used as an example. Please be sure to replace this text with the proper information for your site or server.

Overview

This article outlines the process of reinstalling your DV server to bring it back to a default state. The DV product includes the functionality to do this from within your Plesk Control Panel. You can also reinstall from the Advanced Recovery Tools section of your Account Center's DV Control Panel. We will cover both methods in this article.

Before you start

This article has the following dependencies:

  • Whenever installing third-party software, please consult the official documentation. (mt) Media Temple does not support the installation and configuration of software not installed at time of service activation. Please consult our DV Scope of Support page for further explanation.
  • The domain example.com is used as an example. Please be sure to replace this text with the proper information for your site or server.

Method 1

Using the Account Center Advanced Recovery Tools

This tool will revert your DV to the default state, just like when you first provisioned the server. This will essentially wipe your server and save all of your old data inside of the /old directory on your server. You can only perform an Archive & Reinstall through the Account Center controls.

Instructions

  1. From the DV admin page in your Account Center, select Advanced Recovery. This is located in the Additional Tools menu.
    829_cp_advrecovery_1
  2. Click the Revert to Default button to begin the re-installation process.
    829_reverttodefault
  3. Create new passwords for both the root user and the admin/Plesk user. You will need these when you login to Plesk again, after the Revert to Default is finished.  After you have entered the new passwords, click the Revert to Default button.
    829_revert_newpasswords
  4. Confirm the action, making note of the directory into which your old contents will be placed.
    829_revert_confirm
  5. Wait approximately 15-60 minutes for the process to complete. Depending on how much data you have, the time to complete can vary. The page will show you that it is Pending and will let you know when it has Completed.

Method 2

Using the Plesk/Virtuozzo Reinstall VPS Menu

  • Log into your Power Panel.


    Power Panel

  • Click on Maintenance.
  • Click on the Reinstall tab. If your server is currently running, you will be prompted to stop it before proceeding.
  • Once your server has stopped, click the "Prepare to Reinstall" button.
  • Follow the prompts to continue and make your choices as needed.

NOTE:

  • We strongly encourage changing the root password for your new install after your VPS reinstall is complete using our Account Center tool.
  • If you change your root password via SSH, these tools will not save that password for the reinstall. Please use the Account Center tool to reset your root password. This would be one important step to prevent your server from being compromised moving forward, in case that was the reason for your reinstall.

Restoring Databases After Reverting

NOTE:

The following guide will help you restore your databases from the raw MySQL files that are created after you revert your server to default. While these instructions are usually successful, this process is not fully supported by (mt) Media Temple. Please proceed at your own risk.

For Plesk

  • Log into SSH as root.
  • Run the following command:
     
    
     service mysqld stop
    
       
  • Start up MySQL on a new socket.
     
    
     /usr/libexec/mysqld --user=mysql --socket=/var/lib/mysql/mysql.sock --basedir=/usr --datadir=/restore/var/lib/mysql --user=mysql --pid-file=/var/run/mysqld/mysqld.pid --skip-locking --skip-grant-tables
    
       

NOTE:

That command specifies "/restore/var/lib/mysql" as the path to the raw MySQL files. If they are located somewhere else, you will need to replace this path.

  • MySQL is now running on the server from the data directory you gave it. You will need to open a new SSH window, leaving this one open as well.
  • Make a new directory for your data.
     
    
     mkdir /root/sql_dumps
    
        
  • Create a list of all the databases.
     
    
     mysql -Ns -uadmin -p`cat /etc/psa/.psa.shadow` -e "show databases" | grep -v "information_schema" > /root/sql_dumps/db_list
    
        
  • Dump the databases on your list.
     
    
     for i in `cat /root/sql_dumps/db_list`; do mysqldump --add-drop-table -uadmin -p`cat /etc/psa/.psa.shadow` $i > /root/sql_dumps/$i.sql; done;
    
         
  • Stop MySQL.
     
    
     service mysqld stop
    
         
  • Start MySQL.
     
    
     service mysqld start
    
         
  • All of the databases are now in /root/sql_dumps/ on your server.

When restoring databases, DO NOT import the psa.sql database from your backup files to your newly restored server. The psa database is the internal database for Plesk. If this is restored and overwrites the current version, it will cause issues with your Plesk administration panel.

For cPanel

1. If you haven't done so, log into WHM and go through the initial setup wizard. After this, recreate your cPanel users. 

2. Create databases in cPanel and database users for each of your databases. The database names, users, and passwords must match the old databases. Give the database users proper permissions on their respective databases. If you do not remember the names of your databases, ssh to your server and execute the following:

ls /old/var/lib/mysql

By default, using the database wizard or setup utility found in cPanel will automatically attach the cPanel username to both the database name and username as a prefix. This may prevent you from matching the names of your databases to the originals. To fix this, you must either disable database prefixing in WHM, or create the databases with improper information and then use WHM to rename them afterwards. 

3. Stop MySQL:

service mysql stop

4. Run mysqld in safe mode on a new socket that uses /old/var/lib/mysql as the data directory:

mysqld_safe --user=mysql --socket=/var/lib/mysql/mysql.sock --basedir=/usr --datadir=/old/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/HOSTNAME.pid --innodb_force_recovery=6

 You should see something similar to this:

150502  1:30:41 [Note] Plugin 'FEDERATED' is disabled.
150502  1:30:41 InnoDB: The InnoDB memory heap is disabled
150502  1:30:41 InnoDB: Mutexes and rw_locks use GCC atomic builtins
150502  1:30:41 InnoDB: Compressed tables use zlib 1.2.3
150502  1:30:41 InnoDB: Using Linux native AIO
150502  1:30:41 InnoDB: Initializing buffer pool, size = 128.0M
150502  1:30:41 InnoDB: Completed initialization of buffer pool
150502  1:30:41 InnoDB: highest supported file format is Barracuda.
InnoDB: The user has set SRV_FORCE_NO_LOG_REDO on
InnoDB: Skipping log redo
150502  1:30:41  InnoDB: Waiting for the background threads to start
150502  1:30:42 InnoDB: 5.5.40 started; log sequence number 0
150502  1:30:42 InnoDB: !!! innodb_force_recovery is set to 6 !!!
150502  1:30:42 [Note] Server hostname (bind-address): '0.0.0.0'; port: 3306
150502  1:30:42 [Note]   - '0.0.0.0' 
150502  1:30:42 [Note] Server socket created on IP: '0.0.0.0'.
150502  1:30:42 [Note] Event Scheduler: Loaded 0 events
150502  1:30:42 [Note] /usr/sbin/mysqld: ready for connections.
Version: '5.5.40-cll'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  MySQL Community Server (GPL)&lt

 5. Leave this Terminal window open and SSH into the server in a new window.

 6. Copy your databases using mysqldump. For the code below, replace database_name with your database. Make sure that you copy each database that you need. 

mysqldump -u root -p database_name > database_name.sql
If your mysql access is being denied based on credentials, you may need to stop MySQL and repeat step 4 with an option that skips the grant tables. WARNING: Doing this will cause MySQL to not prompt for a secure log in. This is very insecure and should not be used with everyday database management. 

To stop MySQL, you will need to use the kill command. The kill command must be used instead of service because MySQL is running on a socket other than its default. First, execute the following:

ps aux

Locate the number to the right of the mysql process and use this number, referred to as a PID or process ID, to stop MySQL.

In this case, your code would be: 

kill 2432

Then execute the code from step 4 with the --skip-grant-tables option added to the end: 

mysqld_safe --user=mysql --socket=/var/lib/mysql/mysql.sock --basedir=/usr --datadir=/old/var/lib/mysql --user=mysql --pid-file=/var/lib/mysql/HOSTNAME.pid --innodb_force_recovery=6 --skip-grant-tables 
Now return to step 6.

7. Close the original Terminal window and restart MySQL. Because it has been started on a new socket, you will need to stop MySQL by using the kill command:

ps aux

Locate the number to the right of the mysql process. Your code should look something like this: 

kill 24578

8. Start MySQL back up using the default data directory: 

service mysql start

9. Use MySQL to replace your databases with the recovered .sql data. The password is the current password for your reverted cPanel, which by default is set to a random string. If you are unsure, change the MySQL root password via WHM. 

mysql -u root -p database_name < database_name.sql

Once you have done this for each database that you would like to restore, use MySQL or phpMyAdmin via cPanel to verify that the database information has been restored properly. You may find this article about exporting and importing databases helpful.       

 

This article outlines the process of reinstalling your DV server to bring it back to a default state. The DV product includes the functionality to do this from within your Plesk Control Panel. You can also reinstall from the Advanced Recovery Tools section of your Account Center's DV Control Panel. We will cover both methods in this article.