Today we will discuss about restoring word press website backup step by step.
Existing Landscape: WordPress website is running on Go daddy.
Steps to Restore:
1.) Mostly backup policy depends on rate of content change for the website. Generally speaking it is good practice to have one weekly full backup. In our case we will configure free backup plugin for full backup and redirect backup copy to drop box.
I will have backup placed as a zip in drop box. The good thing with drop box is that it provide user with shareable link which can be unzipped manually on destination instance or can be scripted as well.
2.) Now we will configure AWS instance with lamp role configured on it. We will go with T2 medium type of instance .We will login and install httpd, php and Maria dB.
To know more about installing the EC2 instance in AWS look into the following video. We will be configuring AWS Amazon Linux.
To install httpd in linux use the following commands.
yum update yum install httpd yum install httpd
Configure Mariadb repo.
vi /etc/yum.repos.d/MariaDB10.repo [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.0/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1 yum repolist all yum install MariaDB-server MariaDB-client yum repolist all yum install MariaDB-server MariaDB-client
Now we will do the secure installation of the database to remove anynomyms access and remote root login by using following command.
mysql_secure_installation
Now as we are using amazon linux we will installing php using amazon-linux-extras command
amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2
3.) We have configured the Lamp role. Now we will install WordPress on the instance. First all of we will install the version of word press our website was using. My version was latest hence i ma downloading the latest version.
wget https://wordpress.org/latest.tar.gz tar -xvf latest.tar.gz
All content after untar will be in word press folder
cd wordpress/
4.) We will download the latest backup from the drop box shareable link. Then we will unzip in the WordPress folder.
After we need to sync the word press folder under /var/www/html
rsync -avP ~/wordpress/ /var/www/html/
5.) We need to restore the SQL backup file by importing it into Maria Db. Before doing it we need to create the new database my login into the mysql using below mentioned commands.
sudo mysql -u root create database database-name; grant all privileges on database-name.* to database-username@localhost identified by 'user-password'; flush privileges; exit; Once we have database created we need to import the bckyp *.sql in the downloaded zip using below command mysql -u wpuser -p wpdb < i3349482_wp1.sql
6.) In order to avoid conflicts with redirection we will be adding following lines into the wp-config.php files. Dont forgot to edit the new database, user and password name in wp-config.php
define('WP_SITEURL', 'http://newdomain');
define('WP_HOME', 'http://newdomain');
To see it performed practically step by step checkout the video below.