Cloning Sites with Pagely Sync

Last Updated -

NOTE:This article covers utilizing the Pagely Sync command. it is a useful tool for one time copies of a single site application, to another. For more granular, repetitive, or multisite cloning processes, we recommend using the Pagely Cloning Tool.

The team at pagely has built a great tool called pagely sync for cloning and syncing sites with ease on your VPS. 

SSH into your home directory.

To see a list of available commands run

$ pagely sync --help

You should now see a description of usage along with a list basic commands.

 sync [--ignore-table[="..."]] [--ignore-path[="..."]] [--target-host="..."] [--ssh-identity="..."] [--dry-run] [--skip-file] [--skip-db] [--rename] source target

 source                The source directory
 target                The target directory

      --ignore-table[=IGNORE-TABLE]              Ignore this table while syncing db (multiple values allowed)
      --ignore-path[=IGNORE-PATH]                Ignore this path, rsync rules (multiple values allowed)
      --target-host=TARGET-HOST                  Remote host to use in rsync target
      --ssh-identity=SSH-IDENTITY                ssh identity file to use with rsync
      --dry-run                                  Print what you would do
      --skip-file                                Don't sync files
      --skip-db                                  Don't sync db
      --db-recent-only                           Only sync the last 100 posts from wp_posts (and children) and there matching rows in post_meta
      --limit-to-multisite[=LIMIT-TO-MULTISITE]  blog_id of sites you want to limit the sync to, only applies when db-recent-only is set, repeatable (multiple values allowed)
      --reset-target-db                          Delete all tables in the target db before syncing, useful when the source has a different table prefix, or the target has extra tables
      --rename                                   Update wp_options/wp_blogs and search/replace at target, with targets orginal name (on multisite only renames the primary domain)
  -h, --help                                     Display this help message
  -q, --quiet                                    Do not output any message
  -V, --version                                  Display this application version
      --ansi                                     Force ANSI output
      --no-ansi                                  Disable ANSI output
  -n, --no-interaction                           Do not ask any interactive question
  -v|vv|vvv, --verbose                           Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

If you recently created a sandbox/staging area and would like to clone your production over you can run the following from your home directory:

IMPORTANT: If your source site is using a prefix other than wp_, please be sure you update the target site's wp-config.php with the same table prefix.

Note: You may want to use the --dry-run paremeter first to view which actions will happen without actually running the command.

$ pagely sync ~/sites/production-domain-name ~/sites/sandbox-domain-name

This will clone your existing production site to your specified sandbox domain name, along with importing the database and updating the "home" and "siteurl" in the database.

It a good idea to use the wp-cli search-replace function afterwards to clean up any old url references.

You can also review this article from our friends over at SkyVerge with further details using the pagely sync cloning process.

Related Topics

Pagely is the Managed WordPress Hosting Platform designed to exceed the needs of media, business, and Enterprise customers alike. We help the world's biggest brands scale WordPress.

Copyright © 2006-2017 Pagely, Inc. All rights reserved.
Pagely® and WordPress® are registered trademarks.

Powered by Zendesk