Cloning Environments
After creating staging or development sites, you'll need a way to copy your site's files and database over to your new environment. To make things easy for you, we've created the Pagely Sync and Pagely Clone tools for you to utilize.
In this example, we'll use the Pagely Sync tool, which is useful for one-time syncing from one environment to another. If you need to do more advanced configuration, the Pagely Clone tool is also an option that you might find useful in the future.
Cloning with the Pagely Sync Tool
Cloning your production site over to your new staging environment is easy with the Pagely Clone tool. Here's how to use it:
Since the Pagely Sync tool is a CLI-only tool, begin by logging into your server via SSH.
Once logged in, let's double-check your production site's table prefix using the following command:
(Don't forget to place example.com with your actual production domain)
cat ~/sites/example.com/wp-config.php | grep '$table_prefix'
If your table prefix is
wp_
, you're all set to move on to the next step!If not, you'll need to go ahead and adjust your table prefix in your new staging site's wp-config.php file to match the site that your cloning.
Before making any permanent changes, let's go ahead and do a dry run of the Pagely Sync tool by using the
--dry-run
option:pagely sync --dry-run --rename ~/sites/example.com ~/sites/staging.example.com
As you see from the above command, we're defining the source, the target, the
--dry-run
option to perform a test run, and the--rename
option to perform a search and replace on the target.Did the dry run go as planned? Great! Now, all we need to do is remove the
--dry-run
option to sync from production to staging.pagely sync --rename ~/sites/example.com ~/sites/staging.example.com
As soon as the Pagely Sync tool finishes its operations, your production site should now be successfully cloned over to your staging environment.
Hint: Want to learn more about the Pagely Sync tool? Try running pagely sync --help
or check out the
full Pagely Sync documentation article.
Custom Cloning Profiles with the Pagely Clone Tool
In addition to the Pagely Sync tool, the Pagely Clone tool is also available. Within the Pagely Clone tool, you'll be able to create more advanced custom configurations that allow you to fine-tune specifics.
For this course, we won't be going over the Pagely Clone tool, but you can read more about it on our documentation site.