It has been more than one month since registration in Bluehost WordPress hosting. Bluehost provides relative nice space quota and hardware platform. Although I got some issues struggling with the free SSL problem, the customer services responses swiftly. With the high satisfaction, I decide to extend the package after one money trial. After checking the renewal package, I am surprised that the rate (6.99/m 5yrs) is much higher than initial rate (2.95m 5yrs). To prevent any misunderstanding, I also inquiry with online chat service. Yes, it is true, $6.99/m.
Some people mentions this is negotiable. You need to bargain with customer support multiple times with different personnel. After all that hard work, it still gets about $6.99 (Pro in his example). That is still higher than initial rate. This worries me. To ensure I am capable to move from Bluehost to another hosting service, I decide to do a WordPress backup restore practice.
Note! This article is mainly for restore process verification. Some process doesn’t consider the security issue. All are for simplifying the process. So, if you want to apply to a working site, you need to pay attention on this. Additionally, we use root account throughout the article.
Linux Distribution
Here, we use Ubuntu 16.04 64bits. 14.04 32bits is also ok with some modification due to its old package. For easy operation, 16.04 is chosen. Then, just install Ubuntu on physical or virtual machine.
The backup archive
The backup archive is meant to all things of WordPress. The tough thing is that not all WP hosting service provides complete backup. When I leave WordPress.com, I only get the database backup file. Upload files or and plugins are not included. Maybe someone can get that by contacting their customer support. Since Bluehost provides ssh login, it is no problem to get all things. I backup everything including:
- WordPress database dump file,contains articles and settings.
- WordPress folder,uploaded files, plugins, themes and apache .htaccess file
If you hosting service provides ssh access, following is the simple steps to backup them.
Backup wordpress database
1 |
mysqldump -p<strong>YOUR_DB_PASSWORD</strong> --user=<strong>YOUR_DB_USERNAME</strong> <strong>YOUR_DB_NAME</strong> > ~/wp.sql |
Database name, user name, password are stored at wp-config.php of wordpress. Just search DB_NAME, DB_USER, DB_PASSWORD.
backup WordPress folder
1 |
tar -c -J -f wp.tar.xz public_html wp.sql |
This is quite simple. Just tar everything with the dumped database file. Then, get it back to your PC by any mean.
Linux WebServer Configuration (Apache2)
No small talk. If you use Ubuntu 16.04, just paste commands as below. (assumed root privilege). It installs apache and php.
1 2 3 4 5 6 |
apt-get update apt-get -y install apache2 apt-get -y install php apt-get -y install php-mysql apt-get -y install libapache2-mod-php a2enmod rewrite |
Modify Apache config file to allow .htaccess setting override. Edit /etc/apache2/apache2.conf as below. The key is the “AllowOverride”.
1 2 3 |
Options Indexes FollowSymLinks AllowOverride all Require all granted |
Install MySQL Server. During the process, it will prompt for passwords of root. For simple test, just set it as “123456”.
1 |
apt-get -y install mysql-server |
Add Host Name
If you official WordPress site has its own domain name, the verification process may fail in your local machine due to the connection targeted to the domain name. Or, if you machine is connected to Internet, you may connect to the site online and mislead your to a impress of success. Therefore, we need to apply a local-only domain name to your machine. We can do this by using /etc/hosts on Linux to achieve this. Example with my domain name (moon-half.info),
1 |
echo "127.0.0.1 moon-half.info" >> /etc/hosts |
Restore WordPress
We already finish the server configuration. The next step is to restore the wordpress backup archive to make it work on local machine. The detailed steps is listed below with some comments. In summary, we extract the backup archive “XXXX.tar.gz” and get a “public_html” folder and wp.sql. Basically, we restore the wp.sql to MySQL and move public_html to /var/www/html. (Also assumed ‘root’ in this operation)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
cd # switch to /root for easy operation tar Jvfx /home/ubuntu/moon-half_2018_02_28.tar.xz #extract backup archive mv /var/www/html /var/www/html.old # rename current html folder to prevent unrecoverable problem. mv public_html/ /var/www/html #Move extracted public_html (Wordpress) to system html folder cd /var/www/html # switch to system html folder for easy operation DBNAME=`cat wp-config.php | grep DB_NAME | cut -d"'" -f4` # to get wordpress database name mysql -p123456 -u root -e "create database $DBNAME" # Create WP database to MySQL # Find DB_USER and DB_PASSWORD in wp-config.php, and replace as below # define('DB_USER', 'root') # Modify Wordpress database user name as 'root' # define('DB_PASSWORD', '123456') # Modify Wordpress database user password as '123456' sed -i "s/Header set X-Endurance/#Header set X-Endurance/" .htaccess # Wordpress may use Cache feature,but Ubuntu not support in default,just comment it sed -i 's/https:\/\/moon-half.info/http:\/\/moon-half.info/g' ~/wp.sql # If your WP address is https:// based, we won't support that for local test. So repleace them to http:// to simplify the test mysql -p123456 -u root $DBNAME < ~/wp.sql # Restore the backup database data to MySQL chmod 777 /var/www/html/ -R # for easy operation, change permission to all-writable of system html folder apachectl restart # Restart Apache |
Verifying the Result
In theory, the process is done. To prevent connection to the working site on Internet, I recommend to unplug your network cable to avoid any confusion. Now, you can browse your site inside your Linux box with the original domain name. Due to domain name, connection from outside the Linux can’t connect to that site. If you want to make it work for others, you can change the domain name to IP address in Line 11 of above command table. Or, set hostname correctly in every machine. Simple purpose simple settings, it should be ok to just verifying in Linux box.
Unquestionably believe that which you said. Your favorite reason seemed to be on the web the easiest thing to be aware of.
I say to you, I certainly get irked while people consider worries that they plainly don’t know about.
You managed to hit the nail upon the top as well as defined out the
whole thing without having side effect , people can take a signal.
Will probably be back to get more. Thanks
Happy to know this helps. Blogging is a important measure to keep my memories of my life. So, I quite worry to lose them somehow. Having the capability to restore them is not only for saving money in future renewal. It also prevents any possible server side fault (hacked, server broken, doomday…etc). Actually, I also setup an auto backup on daily-use Windows PC (to save cost) to backup whole site automatically every week.
Thank you for the wonderful article
Heya! I realize this is sort of off-topic however I
needed to ask. Does managing a well-established website such as yours take a massive amount work?
I’m brand new to running a blog however I do write in my journal every day.
I’d like to start a blog so I can easily share my own experience and views online.
Please let me know if you have any ideas or tips for brand new aspiring blog owners.
Appreciate it!
To setup your personal hosted wordpress blog does require some techniques. Learning all things about this may cease your passion to write blog. So, for non-technical blog writer, I would suggest to start from free registration wordpress service like WordPress.com. I provide relative enough stuff to let you learn how to start it and how to make your blog with more view counts. When you have sufficient experience and knowledge, you can try to migrate your data in wordpress.com to your own hosted wordpress blog. This is my opinion for a new & non-technical writer.
Pretty nice post. I just stumbled upon your blog and wanted to say that I’ve really enjoyed browsing your blog
posts. After all I will be subscribing to your
feed and I hope you write again soon! http://www.armidalechurch.com/network/elgg/pg/groups/1693260/apple-patch-diet-mlm-business-review/
Pretty nice post. I just stumbled upon your blog and wanted to say that I’ve really enjoyed browsing your blog posts.
After all I will be subscribing to your feed and I hope you write again soon! http://www.armidalechurch.com/network/elgg/pg/groups/1693260/apple-patch-diet-mlm-business-review/