Advanced Config Guide: Pagely Clone Tool
Last Updated -
This article is part of our Advanced Configuration Series. We'll walk you through the steps of creating a cloning profile and running the tool from CLI or a web interface. We assume you are comfortable with using SSH command line and have a familiarity with basic PHP syntax to set up the cloning profiles. If you're ever unsure or need assistance, our Support Team is just a few clicks away!
Note: You will also need to contact support for the initial configuration of this tool. Additionally, a test run from the command line will need to take place to ensure a new clone profile works as intended. This is a new feature and we'll be making incremental improvements to it. We'll do our best to keep this guide current as that happens.
- About the Pagely Cloning Tool
- Basic stuff
- Configuring a cloning profile
- Configuration Options
- Using the clone tool
About the Pagely Cloning Tool
Pagely's Cloning Tool makes Pagely Sync more repeatable and more flexible. In addition to the capabilities already present in sync, you are able to define an entire workflow and then call it with a more simple SSH command or initiate the sync from a web interface. This system is extremely flexible and even makes it easier to empower the less technical members of your team to perform complex operations on their own. Even if everyone on your team is able to use the standard pagely sync commands, being able to wrap all of the extra steps into a single command is a huge time-saver!
This article covers all you will need to understand the cloning profile, but for a visual representation you can visit our YouTube video...
Video Topics and Timestamps
(Please note that we have changed the "example" directory to ".example", which makes it a hidden directory in linux)
- creating a copy of the cloning profile example
- required predesigned parameters
- additional predesigned parameters
- custom parameters (cli commands)
- ignoring paths, files, and tables
- parameters for multisite
- Cloning tool parameters set for example
- Cloning tool Web Interface showcased
Before you can configure or use clone:
- Contact our Support Team to have the feature enabled
- Have your SSH Access configured and ready to go
- Make sure you are connecting to your VPS with SSH Agent Forwarding enabled:
- ssh -A client_<your_username>@<your_server_name_here>
Configuring a Cloning Profile
Before you can run the actual tool you have to create a configuration file. This specifies the source and destination app IDs as well as any other parameters, like wp search replace or various wp options that should be set after the sync is done. You will create a folder and config file for each cloning scenario (prod to stage, stage to prod would be two separate workflows to set up)
There is an example located at
/data/s####/scripts/.example/conf.php. Make a copy of this by running the following:
cp -a /data/s####/scripts/.example /data/s####/scripts/mysite_prod-to-stage
/data/s#####/scripts/mysite_prod-to-stage/conf.php to specify the parameters.
We recommend creating your first config file with a couple of testing sites to be sure you have the right flow, then repeat for your actual use case.
The configuration options only require the following parameters to be updated in order for it to work...
- source - the source applications absolute file path
- dest - the destination the source application will be clone to. The absolute file path should be provided here as well
- Note: if you type
ll ~/sitesyou'll see the absolute file path of all your applications
- home and siteurl - destination applications home and siteurl.
- pagely_cdn_enabled - whether you want the cloned application to utilize PressCDN
Beyond this, there are many permutations of options available with this tool. It's designed to let you automate the steps you would usually be taking manually when copying a site. We've designed it in a way to facilitate updating options, copying files into place, running WP CLI commands, multisite blog name mappings, and a whole lot more. That degree of flexibility does require a little know-how about what has to happen for your site as well and our team will be happy to assist you in getting the right things dialed in. Just ask!
By default, these additional options are turned off as seen in the image below. A description of each option is below the screenshot as well...
Path or File options
- copy - copy files that might be unique to an application or not specific to any WordPress application. NOTE: if the wp-config.php file is included in this, it MUST be placed in the
/data/s#####/scripts/name-of-clone-profile. It must reside in the same directory as the conf.php you are editing.
- ignore-paths - ignores the specified path during the cloning process
- emailwhendone - will emails the listed email address(es) when done.
- only-recent - Will only sync the last 100 posts from wp_posts (and children) and matching rows to post_meta
- reset-target-db - Resets the target database, ensuring the source database has a clean slate. Useful when the source has a different table prefix, or the target has extra tables
- scheme - changes the protocol scheme from http to https
- skip-db - ignores the database and only clones files
- skip-file - ignores files and only clones the database
- Note: skip-db and skip-file could both be used. A use case for this is if you just want to run specific cli commands, option updates, file copies, etc.
- skip-plugins - will still sync plugin files, but will ignore direct queries that sometimes cause wp cli or pagely sync errors and/or conflicts. This is the same as the wp cli flag --skip-plugins
- skip-themes - will still sync theme files, but will ignore direct queries that sometimes cause wp cli or pagely sync errors and/or conflicts. This is the same as the wp cli flag --skip-themes
- ignore-tables - will ignore the specified tables.
This is one of the biggest advantages to the Pagely Clone Tool. Pagely sync is not equipped to handle some of the granular settings that are necessary for multisite out of the box. These features handle the manual steps Pagely sync required with multisite applications
- multisite - enables the cloning tool for multisite sync
- blogmap - will search for the first argument, and replace it with the second argument
- limit-to-multisite - will limit the sync to only the specified subsites
WP CLI Command Options
Before the the predesigned custom options you'll see the following line...
This section will go uncalled, unless the array cli_cmds is provided options. You'll find the array towards the beginning of the file...
A basic use case for this example is if you want to clear object cache, we can append wp cache flush as a command...
Using the clone tool
This tool is pretty flexible. While it does involve a little bit of initial configuration, once you have it dialed in it's super easy to use and repeatable.
From the web with 1-click cloning
Our Support Team will provide you with the URL to use in order to access the web interface. Once you're in, you'll see all of your workflows that you defined in the configuration section. Clicking clone for the corresponding workflow will get the process started. You can navigate away from the page after you start the process, it won't be interrupted if you do.
From CLI over SSH
Once you have your configs set up the way you like, you can issue commands like:
clone mysite_prod-to-stage clone mysite_stage-to-dev clone mysite_qa-to-stage
The names and the order of flows are completely arbitrary, you're welcome to go with what works best for your approach.