Cloning an Environment

Servd's clone environment tool lets you copy over data and config from one environment to another (e.g. from staging to production).

Tip: It can help a bunch once your project is all set up on staging and ready to be pushed to production.

Cloning from Staging, Development and Production #

Here are a few steps for cloning environments that are hosted on Servd:

  1. Go to your project's staging or production import pages. The page you visit determines which environment is your "target" environment. I.e. if you want to clone into your staging environment, visit the staging page, and likewise for production.

  2. In the "Clone From Environment" section, select the environment you want to import from, i.e. your "source" environment.

  3. Select one or more of the import options:

    • Import assets - Sync all assets stored in your source environment's directory on the Servd CDN with the target environment directory. Note: this will delete any assets in the target directory that aren't present in the source directory.
    • Import database - Replace the target environment database with the contents of the source environment database.
    • Import and deploy selected bundle - Take the bundle currently live on your source environment and deploy it to your target environment.
    • Import new environment variables - Copy environment variables whose keys are present in the source environment, but not the target environment.
  4. Click the "Submit" button.

  5. Wait for the import to complete.

    For projects with large databases or a lot of assets, it's time to go make a coffee. This step can take a little while.

Cloning from Local #

Cloning data from local is a little different, mainly due to the fact Servd can't pull data from your personal dev environment.

If you use the Servd plugin to store your local assets on the Servd CDN, then the clone tool is able to copy assets that live in your local CDN directory over to any other environment CDN directory.

It's worth noting however, that if you have enabled the "Use Local Volumes During Dev" setting in your Servd plugin, the assets stored on your local machine will not be used by the clone. Only those stored in the local directory on the Servd CDN will be.

Cloning to Local #

If you want to pull database data and assets into your local environment, follow these steps:

  1. Confirm you have the Servd plugin installed locally.

  2. If you want to import data from one of your Servd environments into your local environment, run the following craft command:

    ./craft servd-asset-storage/local/pull-database
  3. If you want to import assets from one of your Servd environments into your local environment, run the following craft command:

    ./craft servd-asset-storage/local/pull-assets

    If you have the "Use Local Volumes During Dev" Servd plugin setting enabled, this will download the assets onto your local machine. Otherwise, it will copy the assets to your local Servd CDN directory.

For more information on the available Servd commands, have a read of the Servd plugin docs.