Included with our service is a sitecopy script, that allows you to very easily duplicate a website. The sitecopy script makes a full copy of all files for a website and sets up the connection to a new database. It's a fast and easy solution!
- Start by adding an additional website with us. Our packages all include (at least) 3 web sites. To add a new site in our admin panel, click the plus-sign next to “SITES”. Then select a Site name and click the “Create new site” button. You’ll see a confirmation and receive an email with SSH/SFTP and database information for the new website.
2. Login by SSH to the new website. Change directory to /public and remove our default index page, like this:
Now you need to make sure you have the user info for the website that you want to clone FROM. You need the SSH/SFTP username, password and the server address to clone FROM. You also need the database name, username and password to clone TO (this is sent to you by email, when you set up the new website).
3. Run our sitecopy software, like this:
sitecopy -t wp user-to-clone-from@server-to-clone-from database-to-clone-to -e wp-content/uploads
First we define the type of website to copy (“-t wp”, meaning type=WordPress). Then we set the user/server to clone FROM. Then we set the database to clone TO. Finally we exclude copying the folder wp-content/uploads.
Excluding the wp-content/uploads folder is not a must, but a recommendation. You can do this if you don’t want to store multiple copies of your uploaded files (primarily images). The new website will still work with the images, since we’ll rewrite these through .htaccess (in the final step of this guide).
If you want to copy all folders/files, feel free to remove the “-e wp-content/uploads”. Just make sure you have enough storage space for this in your package.
When you run the sitecopy software, you’ll need to enter the password for the user to clone FROM a few times. You’ll also need to enter the user info for the new database. Other than that, the sitecopy software will manage the whole copying process and database setup for you.
4. Now you need to correct the address to the new website in the database. This is easily done with WP-CLI, like this:
wp search-replace https://website-that-we-cloned-from https://website-that-we-cloned-to --all-tables
The new website address with us can be found in our admin panel, if you select the website and click the “Domains” tab.
Note: If you have a WordPress network installation (WordPress Multisite), you also need to update the address in the database tables
wp_site, and in the WordPress configuration file wp-config.php (if it’s the main address).
5. Finally, we’ll setup .htaccess to rewrite the wp-content/uploads folder (for the images), like this:
nano -w .htaccess
Add the following lines:
# Use uploads folder from production site
RedirectMatch 301 /wp-content/uploads/(.*) https://website-that-we-cloned-from/wp-content/uploads/$1
To close and save the .htaccess file, click ctrl+x, select y (to save) and press the Enter-key.
Now you can visit the new website that you’ve set up, which will be an exact copy of your real/production website.