Restore WordPress Site from Backup

Objective

Restore a WordPress site on a different virtual machine from the backup files.

Prerequisites

  1. A new virtual machine to restore the backup into.
  2. LAMP installed in the virtual machine.
  3. WinSCP

Steps

Step 1: Transfer Backup Files from Old VM to New VM

Open your WinSCP and enter the IP address of the old VM.

Then, transfer the backup files to the desktop. These files should include the following:

  1. database.sql -> database content
  2. wp_backup.tar.gz -> wordpress content
  3. wp_available.tar.gz -> site_available config files

Next, on WinSCP, go to new session and enter the IP address of the new VM.

Then, transfer the 3 files from the desktop to the new VM.

Step 2: Restore Database

Go to MariaDB and create an empty database.

Then, import the database using the following command.

mysql -u username -p new_database < backup.sql

Make sure to grant the privileges of the new database to the same user as the username, with the following command.

GRANT ALL PRIVILEGES ON new_database.* TO wordpressuser@localhost IDENTIFIED BY 'your_password_here';

Note: wordpressuser and the password are the same privileged user the old host.

Then, use the following command to ensure that the changes take effect.

FLUSH PRIVILEGES

Step 3: Extract Backup Data Content

Extract subdomain content to directory /var/www and domain to directory /var/www/html using the following command.

tar -xvf file_name.tar.gz --directory /var/www/

Step 4: Set Up the Website

Then, modify the wp-config.php and change the name of the database to the new one. Modify the following entry:

/** The name of the database for WordPress */
define('DB_NAME', 'wp_backup');

Afterwards, create the directories sites-available and sites-enabled using the following commands.

mkdir /etc/httpd/sites-available
mkdir /etc/httpd/sites-enabled

Then, extract the file wp_available.tar.gz and place the file under sites-available directory with the following commands.

tar -xvf wp_available.tar.gz
mv wp_available /etc/httpd/sites-available

Next, create a symlink from sites-available to sites-enabled.

Then, configure httpd.conf.

Locate Windows host files and enter the following using nano.

nano /etc/hosts

Enter the following:
<your_ip_address> domain.yourwebsite.com

Note that multiple domains must be listed one by one.

Afterwards, restart the Apache service using the following command.

service httpd restart

Finally, test the site via your browser (https://name_of_the_site.com)

Updated on February 3, 2021

Was this article helpful?

Related Articles

Need Help?
Submit a ticket to us and let our professional team assists you

Support Billing Sales
Support
Billing
Sales