Skip to content

Staging sites

It's often useful to make copies of entire websites, so that you can safely test changes to them without affecting the live version. Cito supports Cloning sites, including files and databases. This is achieved with the psclone utility.

Cloning a site for staging

The psclone utility takes two arguments: The domain to be copied, and the URL you wish to clone it as. If you don't specify the second, Cito will automatically generate a subdomain in the format staging.yourdomain.com.

# psclone
Usage: /usr/local/bin/psclone <domain> <staging url>

If no staging URL is specified we use the format 'staging.domain.com'.

The utility will do the following:

  • Create a new domain, php-fpm pool and system user
  • Copy all files in the existing domain's home directory, changing ownership as needed.
  • Copy all databases belonging to the existing user. You can use psmysql to see database ownership.

Caveats and gotchas

psclone does not do the following:

  • Copy cron jobs. These can often have adverse effects when run incorrectly so we do not duplicate them.
  • Modify any configuration files or database content. If your site has hard-coded URL references or other settings, you will need to modify this manually. For example, wp-config.php will need to be updated with new database details after cloning a site.

Example

Cloning testwp.com as staging.testwp.com with username stagetestwp.
[+] Cloning database testwp_wp_A7O as stage_testwp_wp_A7O
[+] Created MySQL database stage_testwp_wp_A7O with user stagetestwp
[+] Note: this script does not modify files such as wp-config.php, or change database contents.
[+] You may need to make additional changes to ensure sites work correctly.
[+] This script does NOT copy cron jobs for safety reasons. This must be done manually.
[+] Site clone complete.