Cloudrovia WS
Sunday October 17, 2021 By Cloudrovia
Here’s how you copy & paste an entire website

A duplicated website is a perfect duplicate of a site hosted on your server. It has the same files, and the contents of its database are identical to the original. The only difference is that the duplicated site is hosted at another domain or directory. 

There are many reasons you might want to duplicate websites on your cPanel server. Because the copies are identical to an existing website, duplicating helps deploy testing and staging sites. It’s also a quick way to set up a new site using the old one as a baseline configuration. Site owners often use duplicated sites to give designers and developers access to a working environment that behaves like the live environment. 

Duplicating can be done on the command line, but it’s time-consuming, and it’s easy to make a mistake. cPanel & WHM automates the more error-prone steps, so you can quickly duplicate sites based on content management systems and eCommerce applications. 

This article looks at two strategies for duplicating sites on your cPanel-managed server:

  1. A generic duplicating process that works for most CMS or eCommerce sites, although we will use WordPress as an example. 
  2. A WordPress-specific process within WordPress Toolkit, which makes duplicating a one-click task by automating copying and site configuration. 

We’ll start with the quickest and most convenient way to duplicate a WordPress site in WordPress Toolkit before exploring a more manual process that will also work with other content management systems. 

Duplicate a WordPress Site with WordPress Toolkit

Open WordPress Toolkit and expand the detail view for the site you would like to duplicate. Click the clone or duplicate tool in the site’s dashboard. 

When the tool opens, select a subdomain and a path to duplicate the site to. If they don’t exist, WordPress Toolkit creates them for you. When you’re finished, click Start at the bottom of the page. 

WordPress Toolkit automatically copies the site, creates a new database and database user, configures the site to use the database, and creates a new subdomain if necessary. Once it’s done, you access the duplicated site as usual. 

How to Manually Duplicate a Website with cPanel

Content management systems—including WordPress, Joomla, and Drupal—are composed of two main asset types. The first is PHP code files and static files such as images, JavaScript files, and CSS. The second is information stored in the site’s database—page content, configuration settings, user information, and so on. 

To duplicate a site, we have to copy both, so the process looks like this:

  1. Create a new folder and copy the site’s files into it. 
  2. Export the original site’s database, create a new database for the duplicate, and import the data into it. 
  3. Configure the duplicate to work with the new database. 

Let’s see how we’d use this process to duplicate a WordPress site.  We’re going to focus on duplicating a site into a new directory rather than a subdomain. 

Create a Folder and Copy the Site’s Files

We can create a folder for the site’s duplicate and copy the files in File Manager, which you can open from the Files section of cPanel’s main page menu.

  1. Select the directory containing the WordPress site you want to duplicate. 
  2. Click Copy in the toolbar and enter a name for the new directory. To keep things simple, we’ll duplicate the site into a directory under public_html so that you can access it from a URL such as “example.com/wordpress_two.” 

File Manager copies the directory and all of its contents, giving you an exact duplicate of the original site’s files. 

Duplicate the Site’s Database

Duplicating the database is a little more complicated than copying files, but it’s straightforward with cPanel’s MySQL tools. 

First, we create a new database. 

  • Open MySQL Databases, which you’ll find under Databases the main page menu. 
  • Enter a name for the new database under Create New Database and click the Create Database button. 

Next, we export the original database.  We’ll use phpMyAdmin, which is also under Databases in the cPanel menu. 

  1. Select the original database in the sidebar.
  2. Select the Export tab and make sure the Quick export method is selected. The custom method lets you change database export options, but we’ll stick with the defaults. 
  3. Click Go.  

This “dumps” the database, downloading an SQL file to your local machine with the information needed to recreate the original site’s database. That’s what we’re going to do next, also using phpMyAdmin. 

  1. Select the new database (the one we created in the previous section).
  2. Click the Import tab. 
  3. In the File to import section, click Choose File and browse to the SQL file you just downloaded. 
  4. Click the Go button at the bottom of the page.

The last step in this section is to give the database a user with a password. You can use an existing database user, but we’ll add a new user and give them a unique password. 

In cPanel, navigate to the MySQL Databases page. Scroll to the Add New User section. 

  1. Under Add New User, enter a username and a strong password. 
  2. Click Create User, and then return to the MySQL Databases page.
  3. Under Add User to Database, select the new user and the database we created in a previous section. 
  4. Click Add, select “All Privileges” on the next page, and confirm the changes.

We now have the files and the database copied, but our duplicated WordPress site is still configured to use the original site’s database. The next task is to configure the duplicate to use its own database.

Edit the Duplicated Site’s Database and URL Configuration

This step is WordPress-specific, but you will have to do something similar for other content management systems. 

  1. Open File Manager and select the new site’s directory. 
  2. Select the wpconfig.php file. 
  3. Click Edit in the toolbar. 

We need to edit several fields in the MySQL settings section of wpconfig.php so that WordPress can access and authenticate with the new database. 

  1. Enter the new database name in the DB_NAME field.
  2. Enter the user we just created in the DB_USER field.
  3. Enter the user’s password in DB_PASSWORD. 

While we have wp-config.php open, we can also tell WordPress about its new URL. There are various ways to do this, but the quickest is to add the following lines, with appropriate changes, to the bottom of the file. 

<! – wp:paragraph – >
<p>define( 'WP_HOME', 'http://example.com/wordpress_two' );</p>
<! – /wp:paragraph – >

<! – wp:paragraph – >
<p>define( 'WP_SITEURL', 'http://example.com/wordpress_two' );</p>
<! – /wp:paragraph – >

Don’t forget to click Save Changes when you’re finished. 

All being well, you should be able to load your duplicated/cloned site at http://your_domain.com/your_subdirectory.

If you’ve followed the examples, that will be something like http://example.com/wordpress_two

As always, if you have any feedback or comments, please let us know. We are here to help in the best ways we can.

Good Luck!


Follow us on social media:

@cloudrovia on Instagram

@cloudrovia on Twitter

@cloudrovia on Facebook

If you’re unfamiliar with our blog, try starting with these:

1. Blog to Business in 6 Steps

2. How to win business in your city.

3. How to build a website that makes money

4. Build your eShop for income in 6 steps

5. You’ve been promoting your business wrong

6. Get started on social media

7. How to Content Market with No Budget

8. Social Media Toolkit