How to make a test-copy of a site

Whenever you upgrade a site with any new software, it is strongly recommended to make a test-copy of the site, and to try the new software there before deploying it to the main live site. It is also very handy to have a test-copy to troubleshoot a problem, and/or to let support personnel login in order for them to see exactly the same screens as you are seeing, instead of making tons of screenshots and writing a handful of paragraphs explaining how to reproduce your problem. Below are a few tips on how to simplify making a test-copy.

  • Review your hosting provider documentation on how to create a subdomain like test.yourdomain.com. It should not cost any extra money. Alternatively, you may run a test copy from a subfolder of the main site.
  • Review WordPress documentation on how to run WordPress from a different directory in case you decide to do so.
  • Once a placeholder for a test-copy of your site is ready, use plugin Duplicator to copy the content of your site and its database to the new place. Plugin Duplicator has an excellent help documentation.
  • It is a good idea to put the whole test site under a password (using .htaccess), so that it never gets memorized by search engines.
  • You can use the test-copy for your own troubleshooting without a risk to break anything at the main site. It is also safe to give us an admin access to your test site to simplify troubleshooting.
  • You may find many plugins, which help to duplicate a site, besides Duplicator, for example, WP Clone by WP Academy or All-in-One WP Migration. Let us know which one works better for you.

Before plugins like Duplicator existed, we used these manual steps:

  1. Log in to access your database (phpmyadmin)
  2.  Select your database (if necessary) – Choose Export
  3.  Use standard.
  4.  Format = SQL and choose “Start”
  5.  Save this file.
  1.  On the server where you want the test site make a new empty database.
  2.  Then go through phpmyadmin to this new database and select it.
  3.  Via the Import button you now import the file that you had just saved.

Then copy all the files from your WP website (with FTP) to the new location on your server. (As an example to folder yoursite.com/test_copy)

  1.  You have to change your wp-config.php file with the details of the new database – username – password – etc.
  2.  Change your .htaccess file as in example shown below:
    From:

    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # END WordPress
    

    To:

    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /test_copy/
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /test_copy/index.php [L]
    # END WordPress
    

Set the appropriate folders (uploads) and .htaccess file with chmod in the way you want them (755 is good).

  1.  Then copy the file search_and_replace.php (download here) to the root of your WP installation in the folder test_copy.(unzip the downloaded file first)
  2.  With the browser you go to:yoursite.com/test_copy/search_and_replace.php
  3.  You will see a page that lets you change the necessary data in the database. (Only the website root, change yoursite.com to yoursite.com/test_copy)
  4.  Note, this must be done carefully a typo is easily made.
  5.  http and www must not be used because some hosts here otherwise deal with it.
  6.  What is important for you to do only the necessary change, then the rest goes automatic.
  7.  Let search and change it …. if it’s good then that’s all.

 IMPORTANT: delete then the file search_and_replace.php

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s