This post is about cloning – copying – and not transferring.
Usually you develop a site either on an external staging server or a sub-domain on the same server and once ready to launch you move everything to the right place, adjust some configuration settings and you are all done. But what to do when the site already is live and in use and the client now request a duplicate site to work on larger changes and wants to see and approve everything before going truly live with those?
Cloning is the answer.
This setup will step through such a situation of using the cPanel and Fantastico while using a subdomain.
There are different options where to put the subdomain: same level as the Joomla install but in its own folder or a sub-directory within the main site such as /public_html/subdomain but outside of the current Joomla directory or outside of the public_html directory all together in /subdomain. I strongly suggest in keeping everything on the server within public_html for safety reasons.
- Once the location has been determined, go within the cPanel to the BACKUP section. Download from MySQL Database Backup the Joomla database.
At this point you could download the full Home Directory from its Backup section as a .zip file and you will need to do this if your clone will be in a different location than within the existing domain. But, for our purposes it is not needed, we will be copying the files on server level – not only will copying the files in the File Manager save time but also bandwidth.
- Install Joomla via the Fantastico panel into the subdomain – once done you will see the following or similar information in Fantastico:
Go visit this fresh install and ensure all is working correctly. Note the URL when hovering over the HOME link: it will show as http://subdomain.domain.com if you installed it into the root of the subdomain.
Now you want to copy all needed files into the new directory, such us custom created media file folders and template folders, next to components and modules etc. – this can be a bit tricky and get messy if you’re trying to copy older stuff into a newer installation (clean install of components and modules is usually recommended).
Having customized plugins and components, it was out of question for me trying to fill in from one to the other installation. On top of it, this new install was at 1.5.11 (via Fantastico) while the current, live site was only at 1.5.8 and non-Fantastico installed. I decided this would be a good opportunity to upgrade the older site in the process of cloning.
To simplify the process delete everything – except configuration.php, fantastico_fileslist.txt and fantversion.php – within the new (subdomain) Joomla install. Ensure you have only these 3 files remaining in the new directory.
You should download these 3 files to the local desktop as a backup.
Then copy all files from the live site to the new site directory, except for the configuration.php file. As the old site was non-Fantastico there was no worries of overwriting such files on the new subdomain.
- Change the 1.5.11 in the fantversion.php file of the subdomain to what the old install was (1.5.8). This will allow us to upgrade the subdomain site to the latest Joomla version via Fantastico. In the future when we move this updated subdomain back into the current live one we can then also upgrade and convert the current site to a Fantastico controlled site – this will be easier for later updates.
- You will need to adjust the .htaccess file for the new subdomain and also edit the configuration.php file. These are the 2 files to modify and most important. This tutorial assumes that you have rewrite enabled in your Joomla install (for pretty URLs etc.). If you can, open the old and new configuration.php file next to each other, compare and adjust as needed. I will not go here into details as you should be at least an intermediate developer when attempting meddling on this level and to do such a clone and in this case you know what to look out for (if not, leave me a comment and I’ll elaborate).
- Insert the downloaded database into the subdomains database. For clean import first drop the content of the Fantastico generated database – do not delete the db, just drop the content [go into database, select all, with selected: drop, confirm you really want to drop] – and then import [import, locate text file to import, select the domain.sql.gz backup file, click 'go'].
At this point you are mostly done. Deep sigh. But don’t breakout the Champagne quiet yet!
Test your cloned installation.
Chances are everything is working fine at this point. It ‘should’ all be fine if you followed the outline above. If you do find problems, check that your configuration.php and .htaccess files truly reflect the new location (subdomain) and database. After that ensure that directories in the new installation have correct CHMOD settings. In my example, our old server needed 755 settings on folders, the new server automatically set them to 777 – if you are having write problems, check in this area if it’s causing you problems.
You have now a cloned, (older) Joomla site in a Fantastico environment – now lets get this updated to the latest Joomla version! Click onto Fantastico and voila! Right there it will let you know that your version is outdated. Click to Upgrade (in this case to 1.5.11).
Before closing Fantastico, ensure to save the information on how to restore if something has gone wrong. It will be a step by step instruction on how to revert this last update and look something like this:
- delete all the files listed in /home/domain/public_html/subdomain.com/fantastico_fileslist.txt
- delete /home/domain/public_html/subdomain.com/fantastico_fileslist.txt
- Untar /home/domain/fantastico_backups/.backup.124546789123.tgz
- Empty the database domain_jo123
- Import the file /home/domain/fantastico_backups//backup.sql into the database domain_jo123
- Move /home/domain/fantastico_backups/ to /home/domain/public_html/subdomain.com
Once you ensured that all is working fine you are done. In the future you pretty much only have to invert the process to move data from the staging server to the live server and you’re all set.