Friday, 11 July 2014

How-to: Copy a site with Plesk Panel


In any systems or website development, there are a couple of golden rules. Always test your code before you promote to Live. Always have a development copy to work on; don't develop on Live. Make your mistakes in the development copy - where you can correct them in private.

In disciplined software development, you could have a number of site copies; local development, Integration site, UAT, Staging, Live; possibly more, possibly fewer, but always with Live separated from the messy business of development and testing. You can quality control your site and promote changes into Live when ready.

But you need to create a copy of the site to work in; whichever way around you do that is up to you, but the process will be commonly like this...


On the current client's server, administration is be done through a common set of utilities; the Plesk control panel allows you to create as many environments as you have space and can manage. You can easily switch between webspaces using the drop-down menu at the top of the Plesk Panel.

The advantage of multiple environments on the same server? A common configuration, and common behaviour across Live, testing, staging etc. The downside? An awful lot more clutter to manage; an all your work is on one box, so if that goes down or you trash it, you better have a solid set of backups!

To copy a site:
Create a domain for the new environment. To add a new domain to the existing webspace, go to Websites & Domains and select Add New Domain. This could be a sub-domain of an existing one. I often use test.mydomain.net or beta.mydomain.net. You could use a completely separate top-level address. Select the domain name to use and configure the DNS settings.

You can add a new webspace on the server by going to Webspaces, Add Webspace, then add a default domain name for the new webspace; select the IP you want to host the domain on (it will safely use the same IP) and fill in your desired login credentials.

Next, copy everything from the production environment to the test environment:
Go to Websites & Domains and click the name of the website you want to copy, then select Website Copying.
  • Select the Website option and choose the destination site name.
  • Choose to keep or delete any existing files on the destination server before copying them, bearing in mind if there are any files with the same name on the destination server they will always be overwritten.
You can use an FTP account on another server, using the FTP storage option; specify the server's host name and credentials for connecting to the FTP account. Plesk expects Active mode for the FTP connection method, but you can choose Passive mode if that's what your external FTP supports.

Website database
Any site using a database will need a copy of this also. Remember to change the database connect string before you start using your test site or else you will write into the wrong copy of the database! If you have copied your Live site for testing purposes... need I illustrate the catastrophe that awaits?

  • Go to Websites & Domains and select Databases.
  • Hit the Copy icon next to the database you want to copy.
  • Choose the destination of the database copy.
  • If you're copying the database on the same server, select the destination server, the Webspace and enter a new database name or select from existing databases. When doing this in Plesk Panel using 'create a full copy' takes the structure and data; without this option, only the database structure is copied empty of data in the tables.
  • Copying the database to a separate server requires you to specify the host name (or IP address) of the remote server to create the new database. Remember if you choose an existing database it will be overwritten!
  • The database copying process will start immediately.If you're copying all existing data along with the table structre, it could take a while. Be patient, keep the faith.
  • Once the copy has completed, modify your website's scripts in the new environment to they connect to the copy, not the original database; modify the connection strings to connect to a new database name, username and password.You may need to create new database users.
Promoting through from development, testing or staging to Live could follow a similar route, but might I suggest you want a more orderly process to control what ends up on live? More on this later. RC

3 comments:

  1. The good news is though that it doesn't have to be unduly complicated and you are probably, in reality, facing only a relatively small number of options. Incidentally, this discussion excludes consideration of website hosting issues. cloning websites

    ReplyDelete

At least try to be nice, it won't kill you...