How to clone a WordPress site
Table of Contents
Maintaining a website is a continuous process, and to be competitive, you often need to update its look and content. Understandably, making major changes and redesigning can be stressful as you never know how your WordPress site will react to them.
This is where a clone of your website comes in handy. It is a copy of your live site with which you can experiment. The changes won’t affect your production site since the clone works independently.
Read the following guide to find out what a clone can be used for and how to clone a WordPress site.
As a website owner, you will find yourself in various situations a clone could be useful. We will list the most common cases below.
Migrating a website to a new hosting
Eventually, you may decide to switch your hosting provider. To make the transition smoother and minimize downtime, you want to make a clone of your website. You can test it on a new hosting environment before you close your current hosting account for good. This way, if anything goes wrong during the transfer, you’ll be able to get a new copy of the original site.
Migrating a website from localhost
Many web developers choose to build a WordPress site on a localhost environment. After the website is ready, they transfer a copy to a hosting server but keep the original in their local environment.
Testing and experimentation
You are considering adding new functionality or updating plugins, but you are worried it may break your website. Creating a staging clone lets you experiment freely, avoiding downtime or fatal errors on your production site.
Redesign
You want to keep the content as it is, but you feel your website looks dated. You can create a staging copy to make the desired changes and replace the live site with the new copy later. In the meantime, your original site will function as usual.
Standalone copy on another domain
You can create a separate copy of your website on another domain. Instead of copying each page or post, you can clone the entire website on a new domain and make changes or remove unnecessary content on the new copy.
The live site and the clone will work separately with their respective domains.
Clone a WordPress site with SiteGround Migrator
The SiteGround Migrator WordPress plugin is a powerful and user-friendly tool that simplifies the process of cloning your WordPress website. This plugin is specifically designed to work seamlessly with SiteGround hosting, ensuring a smooth migration experience.
One of the key strengths of the SiteGround Migrator plugin is its ease of use. With just a few clicks, you can initiate the migration process without any technical expertise. The plugin takes care of transferring your website’s files, database, and configurations, making it a hassle-free solution for cloning your WordPress site.
Another advantage of using the plugin is its compatibility with a wide range of WordPress themes and plugins. This ensures that your website’s functionality remains intact during the migration process. Additionally, the plugin is regularly updated and maintained by SiteGround, providing you with a reliable and secure migration solution.
Compared to other methods, the SiteGround Migrator plugin offers a more streamlined and efficient approach to cloning your WordPress website. It eliminates the need for manual file transfers and database manipulations, saving you time and reducing the risk of errors.
To learn more about the SiteGround Migrator plugin and how to use it, follow this detailed tutorial: WordPress Automatic Migrator.
Clone a WordPress site with SiteGround Staging
Cloning a WordPress site on a staging site is a very common practice. There are various ways you can achieve that – via a plugin or a staging tool provided by your hosting.
The advantage of a staging copy is that the live version and the clone can work on the same hosting, and you can make edits on each version without affecting the other. This way, you can make a major redesign of your website and quickly deploy the changes without suffering any downtime.
SiteGround has developed WordPress Staging Tool specifically for this purpose. It is available on GrowBig, GoGeek, and Cloud Hosting plans.
The tool creates a WordPress site clone of your live site on a staging subdomain. When you are ready to replace the live site with the new staging version, the tool lets you publish the changes with a single click.
If you’re interested to learn more about our tool, feel free to check the SiteGround Staging Tutorials.
Clone a WordPress site manually
Sometimes, the most basic way is the most effective. Although there are plenty of plugins and tools for WordPress cloning, duplicating your website manually is one of the most reliable methods with few complications.
We will go through the entire process of how to manually clone a WordPress site.
-
Step 1.Create a new folder for the clone
To begin with, you must create a folder for the clone. Depending on the available tools, you can use an FTP client or a File Manager on your hosting account.
SiteGround users have Site Tools at their disposal. It has a fully-featured File Manager that you can use for creating and managing files and folders.
Decide if you want to clone the website on a separate domain or a subfolder/subdomain of the live site. Navigate to your Client Area > Websites > Site Tools of the clone’s chosen domain.
Option 1: Create a new subdomain for the clone
If you decide to go with a new subdomain for the clone, navigate to Domain > Subdomains > Create New Subdomain. Write down the unique subdomain prefix and click Create.
In our example, we are creating a subdomain called clone.sg-testing.com. Thus, in the Name field we’ll type clone.
The system will automatically create the subdomain’s root folder – clone.sg-testing.com/public_html. In your case, the folder will be:
subdomain.yourdomain.com/public_html
You can view and access the folder from Site Tools > Site > File Manager. This is the directory where you’ll upload your WordPress files.
Option 2: Create a subfolder on your live site
The other alternative is to create a subfolder where you will upload a clone of your live site. Since the original site has an existing public_html folder, you should create the clone’s subfolder inside.
In this instance, we are cloning the website sg-testing.com on a subfolder named sg-testing.com/clone, so the path to the new folder is sg-testing.com/public_html/clone.
In your case, the path will be:
yourdomain.com/public_html/the_clone_name
To create the folder, navigate to Site > File Manager, open your website’s public_html folder, and hit the New Folder button.
A pop-up window will appear, prompting you to write the folder’s name.
Option 3: Add a new domain for the clone
If you wish to clone the site on another domain, you need to add it to your hosting account. SiteGround users can add Site Tools for a new domain from their Client Area > Websites > NEW WEBSITE.
On the next page, you can choose between three options:
- New domain – select this option if you wish to purchase a brand new domain for the clone.
- Existing domain – choose this option if you want to add a website for another domain you own.
- Temporary domain – select this option if you haven’t decided on a new domain. You will use an auto-generated domain provided by SiteGround. You can later rename the website to an existing domain.
After you make your choice, select SKIP & CREATE EMPTY SITE on the next page. The system will create a new Site Tools panel for your new domain.
The root folder is created automatically, and you can access it from the new domain’s Site Tools > Site >File manager.
-
Step 2.Copy the files of the live site
The best practice when copying numerous files and folders is to create an archived file containing all the data. Navigate to your live site’s root folder and select its files and folders (wp-content, wp-admin, wp-includes). Hit the Archive button and choose a name for the file.
File Manager will create a ZIP archive containing the website. If you wish to download it locally on your computer, select the file and press Download. Your browser will automatically download the file to your computer’s Downloads folder.
-
Step 3.Upload the files to the new folder
Once you have the archive, it’s time to upload it to the new folder. If you are using Site Tools, navigate to Site > File Manager, open the clone’s folder and select File Upload. Then browse for the archive on your computer.
Soon after the upload is complete, the file will appear in the folder. Select it and click on the Extract button in the top bar to unzip the file.
A new subfolder named after the archive file will appear. Open it and select all files and folders to move the website data to your clone’s subfolder. After the files are selected, press Move, which opens a new pop-up window.
On the window, specify the clone’s subfolder in Location and press Confirm to start the move.
-
Step 4.Export a backup of the live site’s database
So far, we took care of the files, but we also need a copy of the live site’s database. The database holds all website data like pages, posts, comments and configuration settings. If you are not certain which is the corresponding database for your site, you can find this out from the wp-config.php file.
Find the database name
Using File Manager, navigate to yourdomain.com/public_html (where yourdomain.com is your website name), select wp-config.php, and press Edit.
Scroll through the file and locate the line where the database name is defined:
define( 'DB_NAME', 'database_name_here' );
Once you have the name, it’s time to download the database. There are a few ways you can do it.
Option 1: Export the database from phpMyAdmin
In Site Tools, navigate to Site > MySQL > PHPMYADMIN, and click ACCESS PHPMYADMIN.
In phpMyAdmin’s interface, select the database name you obtained from wp-config.php. Select Export from the tools, leave the Format as SQL, choose between Quick or Custom Export Method, and press Go. Your browser will automatically download the database on your device in an SQL file named after the database.
Option 2: Export the database from SSH
When it comes to larger databases, SSH is much more reliable and stable. It allows you to establish a secure, encrypted connection to the website’s server over a command-line interface. Since there is no graphic interface with PHP and JavaScript scripts putting a strain on the server, operations run faster. With SSH, you can execute heavier processes and more advanced commands with great ease and success.
For detailed steps, read this tutorial on how to export a MySQL database via SSH.
-
Step 5.Create a new database for the clone site
Now that you have obtained a copy of the live site’s database, you’ll have to set up a new database for the clone.
If you are a SiteGround user, navigate to Site Tools > Site > MySQL > Databases, and click CREATE DATABASE.
You will see the name in a notification on the same screen once the database is created. It is a good idea to save the name since you’ll need it for the following steps.
-
Step 6.Create a new database user and password for the clone site
Every application must have a user in order to connect to a database. So, after the new database is created, you have to create a user that the clone site will be using.
In Site Tools, you can easily create the user from Site > MySQL > Users. Press CREATE USER to create a new user.
Once the user is created, the system shows a notification where you can see the user’s name and password. Make sure to write them down or memorize them.
Next, you need to assign the user to the database. On the same screen, scroll down to Manage Users, where the user is now listed. Under its Actions menu, click on Add New Database, which brings up a pop-up window.
From the drop-down menu Database, select the database you previously created. Leave Set User Privilages to All Privilages, and press CONFIRM.
-
Step 7.Configure the wp-config.php file of the clone site
Now that you have created a database and a user, it’s time to configure your clone site with them. Go back to the File Manager and edit its wp-config.php file.
Find the code defining the database credentials:
// ** Database settings - You can get this info from your web host ** // /** The name of the database for WordPress */ define( 'DB_NAME', 'database_name_here' ); /** Database username */ define( 'DB_USER', 'username_here' ); /** Database password */ define( 'DB_PASSWORD', 'password_here' );
Replace the values with the new database, user and password you created from the previous two steps. Confirm the changes with Save.
-
Step 8.Import the SQL file into the clone’s database
The clone is now connected to a database, but since the database is empty, there is no content on the website. The next step is to import the SQL you previously downloaded from the original database. This way, you copy the site’s content into the clone.
Just like exporting an SQL file, there are several ways to import an SQL file into a database.
Option 1: Import the SQL file from phpMyAdmin
One of the most popular methods is phpMyAdmin. To access it in Site Tools, navigate to Site > MySQL > PHPMYADMIN and select ACCESS PHPMYADMIN.
Select the clone’s database and from the toolbox, choose Import. On this page, click Choose file, which brings a file selector window for your computer. Select the SQL file you downloaded and confirm.
Option 2: Import the SQL file from Site Tools
In real life, 50 MB is a small size for a database, and often your live site would exceed it. That is why we designed a tool for importing large SQL files on Site Tools – Import Database Dump. To find the detailed steps, read this guide on how to import a large database to your account.
Option 3: Import the SQL file from SSH
If you are not a SiteGround user and your hosting doesn’t provide a tool for importing large databases, you can always consider using SSH. You can find a detailed list of steps in this tutorial for importing a database via SSH.
-
Step 9.Configure the WordPress URL of the clone
All the steps above wrap up the entire process of creating a WordPress clone site. There is, however, one final thing to consider; do you need the clone as an inactive WordPress copy of your site, move the site to another hosting server, or intend to clone the WordPress site to a new domain?
If the clone would only serve as a backup or you wish to move it to another server, your job is done. However, if you would like to access and edit the clone separately from the original, there is one final step.
WordPress is a domain-dependent application which means that the paths of all WordPress assets are hard-coded with the original website URL. If you need to access the clone separately from the original, you need to reconfigure the URL with the new domain, subdomain, or subfolder.
How to clone a WordPress site to another domain, subdomain, or subfolder
Changing the site URL for a WordPress site is done from its database. You should edit the URLs in the database you created for the clone by following the previous steps.
In our example, the live site is sg-testing.com, and the clone is sg-testing.com/clone. Therefore, we must replace all database URLs containing sg-testing.com with the new address – sg.testing.com/clone. Similarly, you’ll need to replace your production site’s URL with the clone’s URL.
Read the following guides explaining in detail how to change the URLs in various ways:
Seek assistance from your hosting provider
If you don’t feel confident enough to clone a WordPress site on your own, you can always contact your hosting provider. They can give you some tips, clear any doubts and concerns, or create a clone for you.
Here at SiteGround, we offer professional assistance on various WordPress-related tasks. Cloning/migrating websites is one of our specialties, and we have the experience and proven success of performing thousands of migrations over the years.
You can request cloning of your website from your Client Area > Question Mark icon > View Help Center > Contact Us > Transfer or set up a new site > Cloning an existing site to a new folder or domain.
On the next page, select the production website that will be cloned and add a brief description of your request.
Summary
A WordPress clone can be extremely useful in many situations. The most common scenarios include:
- Experimenting and testing new features on a staging clone of your production site
- Testing a website clone on a new hosting
- Testing a migrated clone from localhost to a hosting server
- Using a clone for experimenting with design changes
- Duplicating the website’s content from one domain to another
The clone is independent of the production site, which allows you to carry out the aforementioned operations with a piece of mind. Creating a WordPress clone is specific, but we hope that this guide cleared the process and helps you choose the most suitable method.