Restoring a Backup of Your Website

A Bit about Backups

television icon 64x64pdf icon 64x64There are many reasons to take a backup of your Website. These include for data integrity, testing and much more. However, just making a backup is not enough. A backup is no backup at all unless you go through the work to make sure that the backup you have will in fact restore something back to the state in which you were backing up for to begin with.

In the last tutorial I demonstrated how to do a full backup of your Joomla website using and extension called Akeeba Backup. I also showed you where the backup files were stored in Joomla in the event you wanted to take the safe route of FTPing the file rather than taking a chance of the file being corrupted by downloading it with the browser.

At this point I assume that you have your backup and it needs to be tested. Testing the restore on you joom.dev site could be a disaster if the backup was bad and you were half done with it. So to test our backups we will create an additional virtual host to test them in. Let’s get started.

Create a new virtual host.

Let’s start by opening a terminal with [CTRL][ALT][T] and changing to the directory that apache uses to hold the virtual sites. You can do this by issuing the following command.

cd /etc/apache2/sites-available

Now that we are in the folder that holds the virtual hosts, lets save a little typing by copying our joom.dev.conf virtual host to another file. We are going to call this site backup.dev and remember that the file has to end with the .conf extension. You can make a copy of the file with the following command.

sudo cp ./joom.dev.conf backup.dev.conf

With the new file created, we need to edit it to reflect our new virtual host. Open the backup.dev.conf file for editing with the following command.

sudo nano backup.dev.conf

Now we need to make some changes to the file. With the nano editor, change the file so that it looks like the one below.

<VirtualHost *:80>
ServerName backup.dev
ServerAlias www.backup.dev
DocumentRoot /home/joeh/Desktop/backupdev/

<Directory /home/joeh/Desktop/backupdev/ >
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

LogLevel info
ErrorLog ${APACHE_LOG_DIR}/backup.dev-error.log
CustomLog ${APACHE_LOG_DIR}/backup.dev-access.log combined
</VirtualHost>

You will notice, that we changed all instances of the work joom to backup. With these changes made, we need to save the file. To do so, press [CTRL][X] to exit, [Y] to save the buffer and then the enter key to save the changes to the file.

With the virtual host file created we need to create the folder that the site will live in. Looking back up at the virtual host file, you see that we said it would be on the desktop in a folder called backupdev. Let’s create that folder now with the following command.

mkdir ~/Desktop/backupdev

That takes care of that. Next we need to enable the virtual host so that apache can find it. We can do that with the following command.

sudo a2ensite backup.dev.conf

Apache should have informed you that it is enabling the site and that the configuration needs to be reloaded before the changes can take effect. To restart apache enter the following command.

sudo service apache2 restart

Now that apache has been restarted we are almost done. Next we need to give it some means of resolving the name backup.dev to the local machine. We can do this exactly the same as we did last time by making another entry in the hosts file. Open up the hosts file for editing by issuing the following command.

sudo nano /etc/hosts

With the hosts file opened up for editing, add the following line under your joom.dev lien in the file.

127.0.0.1 www.backup.dev backup.dev

Now we need to save the file. Do so by pressing [CTRL][X] to exit [Y] to save the buffer and the enter key to save the file.

Everything is in place for the new virtual host except for creating test index.html file to test out the virtual host with so let’s do that now. Create a index.html file in the backupdev folder by issuing the following command

touch ~/Desktop/backupdev/index.html

The touch command will create an empty file. Now let’s open the file and write a simple html webpage to test with. Open the file for editing by entering the following command.

nano ~/Desktop/backupdev/index.html

With the file opened up for editing, write the following HTML code.

<html>
<head>
<title>Backup.dev Test</title>
</head>
<body>
<h2>Backup Testing Site</h2>
<p>This is a test of the backup.dev site for backup testing.</p>
</body>
</html>

Save the file as above by pressing [CTRL][X] to exit, [Y] to save the buffer and the enter key to save the file.

Everything should now be in place to use the new backup.dev virtual host. To test our work, open your browser and point it to http://backup.dev. If all went well you should have a web page that looks something like the image below.

013 001 Virtual Host

Getting Akeeba Kickstart

In oder to do a site restore we need some more software from Akeeba called Akeeba Kickstart. Open you browser and point it to https://www.akeeba.com. When you land on their front page you will see a box titled Akeeba Kickstart. Click this box to go to the download page.

When you arrive at the download page, you will want to download the Core software. Do so by clicking the button and saving the file to your computer. See the image below.

013 002 Akeeba Website

With the file saved we have all the tools we need to do the site restore, we have the Kickstart software and the JPA backup file we saved from Akeeba Backup.

Doing a Site Restore

To do a site restore we only need to extract the kickstart archive and copy our backup to the backupdev folder we created earlier and create a database for our backup to use, then finally run the kickstart application, so let’s get going.

Creating the database

Our restored site will need a database set up to restore to. We obviously do not want to use the database we created for our joom.dev site, so let’s create a new one. Open phpMyAdmin in your browser and log in. Once your logged in click the database tab at the top and the screen will change and allow us to create a new database. For the backup testing, I created a database called akeeba_test, you can name yours what you want, click the create button to create the database. See the image below.

013 003 phpMyAdmin

With the database created for testing our backup we can now close phpMyAdmin down as we do not need it for anything else.

Copy the Archive Over

Now copy the backup file you created to the backupdev folder on your desktop from where ever you saved it to.

Extract Kickstart

Next we need to extract the Kickstart core file we downloaded from Akeeba to our backupdev folder on the desktop. If your file is in the Downloads folder you could use the command below to extract it from the command prompt, or you can use the archive manager if you like. Pick your poison.

unzip ~/Downloads/kickstart-core-4.2.1.zip -d ~/Desktop/backupdev

If you are using the command line be sure to check the name of the zip file because you may have a different version of the file than I have. When you extract the Kickstart software, you will see that quite a number of files are extracted. In reality you only need four of them. These are kickstart.php, jquery.min.js, json2.min.js and the specific language file for your language. Notice the two character prefix to all the INI files, these are the language files and for English I would need the one that starts with en-GB. These prefixes are the same as you would encounter with Joomla language files. Howver, it does not hurt to leave all the files because Kickstart will clean up after itself.

Now, before we start the restore, be sure to delete the index.html file we created for testing. If you do not, it will override Joomla’s index.php file when we go to load the web page after restoring.

Restoring from the Archive

Open your browser and go to http://backup.dev/kickstart.php to start the restore process. You will see the screen below.

013 004 Akeeba Kickstart

After you have read the information, either click the link or press the [ESC] key. Once you close this notice you will be presented with the first screen of Akeeba Kickstart. There are four sections to this first screen. Section 1 allows you to pick from a URL to get the archive file, but will automatically pick up the archive if it is in the same directory as the kickstart.php file we launched. In the screen shot below you will see that it has filled this in for us.

Section 2 allows you to select how you want to extract your backup. By default Akeeba Kickstart will use the Hybrid method, meaning that it will do a direct extraction if it can and if that fails will use FTP services if they are set up.

Section 3 allows you to fine tune the extraction process if you need to. In most cases you don’t need to bother with making changes here.

Finally, in section 4 we have a button that will start the extraction process.

013 005 Akeeba Kickstart

013 006 Akeeba Kickstart

After clicking the start button, Akeeba Kickstart will extract the file and then display a screen that will allow you to run the installer. See screen shots below.

013 007 Akeeba Kickstart

013 008 Akeeba Kickstart

At this point you can click the Run the Installer button. When you do, Kickstart will initalize and present you with the first screen of the installer. This screen displays the settings it has detected with your server environment and backup archive and gives you a chance to go and make changes before proceeding. You can click the next button and go to the next screen. See screen shot below.

013 009 Akeeba Kickstart

On the next screen you will need to enter in some database data to do the restore. For the database server it would be localhost, for the username and password you will need to enter in the username of root and the password you set in the LAMP tutorial for your MySQL server. Finally, you need to enter in the name of the database your created above. Mine is called akeeba_test. See screen shot below.

013 010 Akeeba Kickstart

Once the information has been entered you can click the next button. This will start the database restore process. See screen shot below.

013 011 Akeeba Kickstart

Once the database has been restored you are presented with a dialog indicating it was successful. Click the Next Step button to continue. See below.

013 012 Akeeba Kickstart

The next screen allows you to change some of the information about the site. Kickstart will have picked all the meta-data information about your site from the archive that you extracted, but you can change some of it here if you like. The important part of this screen is, you need to set the administrator password. Enter in your password and repeat it, then you can click the next button. See image below.

013 013 Akeeba Kickstart

When you click next you will be presented with a screen that says your almost done, all you need to do is clean up. You can close this tab, because if you look closely, Kickstart has another tab open. You you look at it you will see it has a button that reads Clean Up. See image below.

013 014 Akeeba Kickstart

013 015 Akeeba Kickstart

Now click the Clean up button and you will be presented with a screen with two button, one sending you to the sites front end and another that will send you to the site’s back end. See below.

013 016 Akeeba Kickstart

At this point the site restore is complete. Click the buttons to see the site’s front and back end and verify that all is working as expected. It took much longer to explain how to restore your site than it does in practice. I encourage you to go through the process a few times and get comfortable with it. You should always test any backup you make to a site, because if you assume it is good and some emergency comes up where you do need to restore and you find that your backup is bad, well… I dare not think of the consequences.

In my test backup site, when I want to reuse it, I simply delete all the folders from the web root of the backup test site and drop all the tables from the akeeba_test database and reuse it over and over.

I hope this tutorial has been a help to you and that the mystery, if any, is washed away when it comes to disaster recovery and your websites. If you have any questions, please contact me by going to http://www.myheap.com and using the contact us menu at the top of the page. Thank you for your support.

END OF TUTORIAL