HTML Logo by World Wide Web Consortium ( Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS. ocPortal 9 is superseded by Composr 10.

Head over to for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.

How to clone your ocPortal site

Have you ever wanted to know exactly what impact a specific upgrade, patch, addon, or change will have on your live site but were too afraid to try?

With the following instructions you can now find out exactly by creating a clone of your site and applying the changes to the clone.


While the steps may seem a bit long-winded and fiddly, they should be straight forward enough. Please read the instruction completely first as you will need place your specific details in place of the following place holders:

   MAIN_SITE_DIR      ←The director where you installed your main site

   CLONE_SITE_DIR      ←The director where you installed your clone site

STEP 1: Install a fresh copy of ocPortal. This will be your clone site. If you already have another ocPortal site installed that you want to re-use and make your clone site then ignore this step.

STEP 2: Use the ocPortal upgrader tool ( to flush the caches of your master site. There is no need to close the site.

STEP 3: Backup the database of your main site by executing the following command in a shell (ssh) window, taking care to first replace the place holders with your specific details:


mysqldump -u MAIN_DB_USERNAME -p MAIN_DB_NAME --password=MAIN_DB_PASSWORD > main_db_backup.sql

STEP 4: Prepare the clone site's database to accept main site's database using the following ssh command (change place holders as required):


mysql --user=CLONE_DB_USERNAME --password=CLONE_DB_PASSWORD -BNe "show tables" CLONE_DB_NAME | tr '\n' ',' | sed -e 's/,$//' | awk '{print "SET FOREIGN_KEY_CHECKS = 0;DROP TABLE IF EXISTS " $1 ";SET FOREIGN_KEY_CHECKS = 1;"}' | mysql --user=CLONE_DB_USERNAME --password=CLONE_DB_PASSWORD CLONE_DB_NAME

STEP 5: Replace the clone site's database with that of the main site using the following ssh command (change place holders as required):


mysql -u CLONE_DB_USERNAME -p CLONE_DB_NAME --password=CLONE_DB_PASSWORD < main_db_backup.sql

At this point you can delete main_db_backup.sql if you wish (by executing the rm main_db_backup.sql command in the ssh window). I sometimes don't if I'm going to be playing around with the tables of my clone site directly. So if I stuff something up I can just do steps 4 and 5 and I'm good to go.

STEP 6: Now, to clone the rest of the site. In cPanel do the following:

   a) rename CLONE_SITE_DIR directory to CLONE_SITE_DIR_OLD. The main reason for this is to protect the .htaccess and info.php. If you are short on space then you can delete all files except those two.
Note: The first time you set up a clone site you might actually need to copy .htaccess from MAIN_SITE_DIR to CLONE_SITE_DIR_OLD and check if there are any site specific paths that need changing.

In my case there are two entries that have site specific paths The first is the ErrorDocument line, which ensures that 404 pages are displayed properly, and the second is a AuthUserFile line to ensure password protected directories work (I password protected my main site while it was in development).

Also, if your main site is based on recommended.htaccess then .htaccess should be copied otherwise you will most likely get Not Found errors when trying to access the cloned site.

   b) navigate to MAIN_SITE_DIR folder and select all files and folders in that folder.

   c) select copy function and change destination path from "/public_html/" to "/public_html/"

   d) copy the following files from "CLONE_SITE_DIR_OLD" to "CLONE_SITE_DIR" to ensure that the cloned site will work correctly:

   e) delete CLONE_SITE_DIR_OLD directory

Congratulations!!!, you should now have a working clone of your main site!

A few things to note about the cloned site.

1) Its live, so anyone who has access to your main site has access to your clone site. If you don't want them to see the clone and the things under development you can either close the clone site (so only admins will be able to log in) or password protect the CLONE_SITE_DIR directory using cpanels Password Protect Directories feature.

2) Although the bulk of the clone site uses dynamically generated URLs which will automatically adjust to the new location and URLs, any URLs you have hard coded or that appear in content will still point to the main site. The classic examples of this are the URLs in spacer posts. This has never been an issue for me.

3) Because the clone looks identical to the main site you might want to consider making some small but obvious change to the look of the clone so that it is easily distinguishable from your main site.

4) User notifications will still be active, so if you reply to a members post (say for example you are testing that post reply still works), and they have email notifications turned on, they will receive the email notification.

These instructions were originally posted and discussed in View topic: How to clone your ocPortal site - .

There are no pages beneath this page

Submitted by Fletch

I know it is a bit late to say this now (for ME, that is!), but your steps 3, 4, and 5 confused the hell out of me. In particular, the reference to the 'ssh window' bit. Didn't have a clue (still don't) what you were talking about, so I carried out the tasks using the tools in phpMyAdmin.

It appears I managed to get there in the end, because my 'clone' site has worked from the 'get-go' exactly as you described it should.

For me, and anybody else that feels the 'confusion', please explain the 'ssh window' concept, where it is used, and what it does that isn't accomplished by using the phpMyAdmin tools.


Submitted by temp1024
Sorry for the late reply Fletch, I only just noticed your comment :$ .

When I say "ssh window", I'm referring to the use of a Secure Shell console (terminal) application. Its the 'standard' secure tool/method of remote communication with a server.

Its a command-line tool (like OcCLE). The advantage of using ssh over phpMyAdmin is that you can script/automate steps to do things simpler/faster/consistently.

Note that some hosts have SSH access disabled by default, and depending on your host, you would activate it either through your hosts self-service tools or by sending a them a support ticket.
Submitted by chipster
Thanks so much for the tutorial. I've tried making a copy of my site before using ocPortal's importer tool, but have had problems at times especially when it came to catalogues.  This method worked for me flawlessly and only took a few minutes to execute. A sure winner.  Again thanks.
CEDI change-log Post