Site Cloning

Site cloning allows you to quickly create a complete copy of an existing site on SpinupWP, which includes all files, the database, and server configuration (Nginx and PHP-FPM). Cloning is useful for creating staging sites or for quickly testing server configuration changes. For example, you could test upgrading your site to a newer version of PHP in an isolated manner without impacting your production site.

To clone a site, head over to the site’s settings screen and click ‘Clone Site’ in the top right corner.

Clone a site

This will open the site cloning wizard, where you can configure the new domain, database, and site settings (PHP version, page cache). For git-based sites, you will also be able to select the new branch to check out and modify your deploy script (if required).

Clone site wizard

When a site is cloned, the following actions are performed:

  • Create new site user
  • Install selected PHP version (if not already installed)
  • Copy existing PHP pool config
  • Find & replace the domain in the PHP pool config file
  • Copy all existing Nginx config files to the new domain directory
  • Find & replace the domain in all Nginx configs
  • Symlink new sites-available config file
  • Copy all site files (including git files) to the new domain directory
  • Checkout selected branch (if git site type)
  • Copy cron config (including custom cron entries)
  • Find & replace the domain in cron
  • Copy logrotate config
  • Find & replace the domain in logrotate config
  • Copy database
  • Update database credentials in wp-config.php or .env
  • Find & replace the URL in the cloned database
  • Enable HTTPS (if enabled)
  • Enable the page cache (if enabled)
  • Reload Nginx
  • Reload PHP-FPM

After cloning a site, we recommend you test your site thoroughly and check any Nginx config files you might have added or customized.

Once a site has been cloned, it functions like any other site in SpinupWP.

Unable to update site’s wp-config.php file

If, after cloning your site, you’re presented with the following error message, you must manually update your database credentials. It’s vitally important that you manually do this, otherwise, your cloned site may be using the original site’s database. Meaning, changes made to your cloned site may impact your original site.

Site cloning failed to update wp-config.php

SpinupWP will try to determine where your database credentials are stored. For most sites, this will be your wp-config.php file. However, for git-based sites, it’s common to use a .env file.

When attempting to update your database credentials, SpinupWP will first look for a .env file in your site’s files directory (/sites/DOMAIN/files/.env). If this file exists, SpinupWP will look for a DB_NAME environment variable. If a .env file is found but no DB_NAME environment variable exists, SpinupWP will show the above error message. Using SSH or SFTP, you will need to update your .env file to reflect the new database credentials.

DB_NAME='cloned_database_name'
DB_USER='cloned_database_user'
DB_PASSWORD='database_password'

If your site does not have a .env file, SpinupWP will recursively search your site’s PHP files (excluding wp-config-sample.php, *.sample.php, and setup-config.php) for the DB_NAME constant. If more than one match is found, SpinupWP will show the above error message. Using SSH or SFTP, you will need to update your wp-config.php file to reflect the new database credentials.

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define( 'DB_NAME', 'cloned_database_name' );

/** MySQL database username */
define( 'DB_USER', 'cloned_database_user' );

/** MySQL database password */
define( 'DB_PASSWORD', 'database_password' );

Once you’ve updated your database credentials, we recommend that you perform a find and replace on the cloned database. This will ensure that your links are updated to reflect the new domain name. You can use WP-CLI to do this:

wp search-replace '//old_url' '//new_url' --network
wp cache flush

Start Your 7-Day Free Trial

Start your SpinupWP journey today and spin up your first server within minutes.

Start Your Free Trial

No credit card required

Subscribe to get the latest news, updates and optimizations in performance and security.

Thanks for subscribing 👍

To receive awesome stuff, you'll need to head to your inbox and click on the verification link we sent you.
Make sure to check your "spam" folder or your "promotions" tab (if you have Gmail).
If you're still having trouble, then messages us at sudo@spinupwp.com.

You are already logged in

It looks like you are already logged in to SpinupWP.

Please log out of this account to continue.

Registration Successful

Thanks for registering for a new
SpinupWP account.

Before getting started, could you verify your email address by clicking on the link we just emailed to you?

SpinupWP

Free Trial

Start Your 7-Day Free Trial

No credit card required. All features included.

By signing up to SpinupWP, you agree to our Terms and Conditions.
For privacy related information, view our Privacy Policy.