Web Admin: Krystal: Replicating the Live Site

From U3A Support
Jump to navigation Jump to search

Introduction

Whilst the Staging Site is a fantastic tool for development and testing, there is a good argument to have a copy of the website on a local server for teccy types to play around with. This is not the same as Cloning - which clones the live site to a sub domain of our website, nor is it the same as staging - for pushing changes to the live site. A replicated site sits on a different server, in this case a local server on your own PC and operates independently of the live site. Cloning the Live site is covered in a separate article: Cloning/Staging the Live Site.

The Process

Whilst I initially tried to use backups from Krystal I got in a bit of a muddle. Our Krystal account hosts the Live site, the Staging site and the Support site. We don't need all of these, we just need the main website. Together with the backups from Krystal I first installed a clean version of WordPress on my local server and then the intention was to build it up from there, importing the backup of file structure and the database - it didn't work.

Having spent a few days faffing around, not getting anywhere I nevertheless did learn a lot about how WordPress works. I then started again with my renewed knowledge and once I had the right files in the right place it then took less than five minutes to edit the necessary configuration/option files to suit my environment and lo and behold my local site was working. This article assumes that you have the knowledge and skill set to set up a local web server such as wampserver

The File Structure

I decided to replicate the live site rather than staging. A clean install of WordPress shows the following files structure:

WordPress file structure
Default WordPress installation files

Our live site includes a bit more and it is not at the root level of the account. To get there you have to navigate: Root/Home | public_html | Shrewsburyu3a and the WordPress installation is there. I didn't use a backup, I just FTP'd these files / folders and their subfolders down to my local computer.

Live site file structure
The Live site file structure

These are the files you need at the root level of your local website on your local server. I called my site "U3A". This is how my file structure works:

wamp64 | www | u3a

Local file structure
Local File structure

With the file structure now in place we can now move on

The Database

Access PHPMyAdmin from the Krystal Control Panel and export a copy of the live database. Save it to your local computer. You can leave all the default settings as they are.

Open PHPMyAdmin (or equivalent) on your local server and create a User and Database. You could give them your own names, but I kept the same names already in use. Note that the database name and user name are different. You can view the database details in the wp-config.php file that you have downloaded and copied to your local server.

Currently, your newly created database will have no tables within it. Select the database and now import the downloaded database from the live site that you saved earlier. Your database should now be fully populated.

Select the wp-options table and edit the siteurl and home fields to your specific details. In my case http://u3a

The wp-options table
The wp-options table

Also in the wp-options table, edit the admin_email field to one of your email addresses. (WordPress sends an email for example when plugins are automatically updated)

Final Adjustments

Exit out of PHPMyAdmin, navigate to your new URL in your browser and you should be done. So that I wouldn't get confused with which site I was working on, be it Live, Staging or my local site. I edited the template to change the colour of the Yellow Menu Bar. In my case I chose the secondary colour "u3a Red" (#ee695a)

A red YMB
A red YMB

To do this, access the WordPress Dashboard, go Appearance | Themes | Select the Active Theme (U3A) and then Customise | Additional CSS.

Edit the value of the header-text-nav-container to suit. In this screenshot I have already changed it from U3A Primary Yellow (#ffc700) to U3A Secondary Red (#ee695a). Publish (save) your changes and exit out of WordPress.

Edit CSS for a different colour
Edit CSS

Auto-generated emails

To prevent automatically generated emails being sent, you could comment out the Mailgun lines at the bottom of the U3A Configuration file (wp-content | plugins | u3a-website | config.txt)

Keeping your local copy up to date

Similar to cloning the live site to Staging on a monthly basis, it is recommended that you local copy is kept up to data (with database records) on an 'as required' basis. This is a four part process:

  • Export the live database
  • Drop the tables form the database in your local copy
  • Import the exported database
  • Finalize with option tweaks

Exporting the live database

Select the database from the left hand pane of PHPMyAdmin and then the export tab

Exporting the database
Exporting the database

On the next screen you can leave all the settings at their default and simply click "Export". Download to a location of your choice.

Drop the tables from the database in your local copy

On your local copy of PHPMyAdmin, with the whole database selected in the left hand pane, the Structure tab is the default in the right hand pane. Scroll to the bottom and click the "Check all" checkbox. Then from the "With selected" drop down options, select "Drop". this will remove the tables from the database - which is what we want.

Dropping tables from an SQL Database
Dropping tables from an SQL Database

Importing the exported database

Importing your exported database from the live site is quite simple. Select the database in the left hand pane, and then 'Import' from the top row of tabs.

Navigate to your chosen file and then click "Import" from the bottom of the page. You can leave any optional settings at their default.

Importing a database
Importing the database

Finishing up

Unfortunately, having imported a fresh copy of the database you will have overwritten any previous changes. So we now need to redo those. Navigate to the wp_options table and make the changes as identified above: 'siteurl', 'home' & 'admin_email'. Then to finish, change the colour of the Yellow Menu Bar as also described above. Job done🙂.

Navigate to the previous or next article