Skip to content

env

A site has a live environment and optionally one or more staging environments. The env commands manage those environments and move content between them. For actions on the whole site, see sites.

Terminal window
kinstactl env list my-site
kinstactl env clone my-site dev --from live
kinstactl env push my-site --from staging --to live

Commands that change an environment wait for Kinsta to finish by default, and accept --no-wait, --timeout <minutes> and --dry-run; see operations. --dry-run prints the resolved target and the request that would be sent, and changes nothing.

List the environments of a site.

Terminal window
kinstactl env list my-site
kinstactl env list [site] [options]

List the environments of a site

Arguments

ArgumentDescription
sitesite name, display name or ID

Kinsta API: GET /sites, GET /sites/{site_id}/environments

Use it to find the names you pass to --env on other commands.

Push the database and/or files of one environment to another.

Terminal window
kinstactl env push my-site --from staging --to live
kinstactl env push [site] [options]

Push the database and/or files of one environment to another

Arguments

ArgumentDescription
sitesite name, display name or ID

Options

OptionDescription
--from <env>source environment
--to <env>target environment (gets overwritten)
--no-dbdo not push the database
--no-filesdo not push files
--no-search-replacedo not run search and replace on the database
--path <path...>push only these paths instead of all files
--dry-runprint the resolved target and request; change nothing
--no-waitreturn the operation ID instead of waiting
--timeout <minutes>give up waiting after this many minutes (default 30)
--yesskip the confirmation prompt

Global options --profile, --json and --no-input apply too. See scripting and CI.

Kinsta API: GET /sites, PUT /sites/{site_id}/environments

--to is overwritten with the content of --from, so the command asks for confirmation first. On a terminal you answer a prompt. In a script, pass --yes, otherwise it fails with CONFIRMATION_REQUIRED (exit code 5). Without --from or --to, a terminal asks which environment you mean; in a script both are required, and they must be different environments.

By default the database and all files are pushed, and a search and replace is run on the database. Narrow that down with the --no- options:

Terminal window
kinstactl env push my-site --from staging --to live --no-db --path wp-content/themes --yes
  • --no-db and --no-files skip one half of the push. Pushing neither is a USAGE error.
  • --no-search-replace skips that search and replace.
  • --path pushes only the given files or folders instead of all files, and cannot be combined with --no-files.

Create a new environment for a site.

Terminal window
kinstactl env create my-site dev --admin-user admin --admin-email [email protected] --admin-password -
kinstactl env create <site> <display-name> [options]

Create a new environment for a site

Arguments

ArgumentDescription
sitesite name, display name or ID
display-namedisplay name of the new environment

Options

OptionDescription
--plaincreate an empty environment without WordPress
--premiumcreate a premium staging environment
--admin-user <name>WordPress admin user name
--admin-email <email>WordPress admin email
--admin-password <password>"-" reads it from stdin; omitted on a TTY prompts for it
--title <title>site title (default: the display name)
--language <code>WordPress language
--multisiteinstall WordPress as a multisite
--subdomain-multisitemake the multisite use subdomains
--woocommerceinstall WooCommerce
--yoastinstall Yoast SEO
--dry-runprint the resolved target and request; change nothing
--no-waitreturn the operation ID instead of waiting
--timeout <minutes>give up waiting after this many minutes (default 30)

Global options --profile, --json and --no-input apply too. See scripting and CI.

Kinsta API: GET /sites, POST /sites/{site_id}/environments, POST /sites/{site_id}/environments/plain

By default the new environment gets a fresh WordPress install, so it needs the admin user, email and password, like sites create. Pass --plain for an empty environment without WordPress, and --premium for a premium staging environment.

Clone an environment into a new environment of the same site.

Terminal window
kinstactl env clone my-site dev --from live
kinstactl env clone <site> <display-name> [options]

Clone an environment into a new environment of the same site

Arguments

ArgumentDescription
sitesite name, display name or ID
display-namedisplay name of the new environment

Options

OptionDescription
--from <environment>environment to clone
--premiumcreate a premium staging environment
--dry-runprint the resolved target and request; change nothing
--no-waitreturn the operation ID instead of waiting
--timeout <minutes>give up waiting after this many minutes (default 30)

Global options --profile, --json and --no-input apply too. See scripting and CI.

Kinsta API: GET /sites, POST /sites/{site_id}/environments/clone

This is the quickest way to get a staging copy of live. To clone into a new site instead of a new environment, use sites clone.

Delete an environment.

Terminal window
kinstactl env delete my-site --env staging --confirm my-site
kinstactl env delete [site] [options]

Delete an environment

Arguments

ArgumentDescription
sitesite name, display name or ID

Options

OptionDescription
--env <environment>environment name or ID
--dry-runprint the resolved target and request; change nothing
--no-waitreturn the operation ID instead of waiting
--timeout <minutes>give up waiting after this many minutes (default 30)
--confirm <site-name>the site name, to confirm an irreversible action

Global options --profile, --json and --no-input apply too. See scripting and CI.

Kinsta API: GET /sites, DELETE /sites/environments/{env_id}

Deleting an environment cannot be undone, so --yes is not accepted. Confirm by typing the site name when prompted, or pass it as --confirm <site-name> in a script. Run it with --dry-run first to check which environment is selected.

Change the PHP allocation of a premium staging environment.

Terminal window
kinstactl env php-allocation my-site --env staging --threads 4 --memory 256
kinstactl env php-allocation [site] [options]

Change the PHP allocation of a premium staging environment

Arguments

ArgumentDescription
sitesite name, display name or ID

Options

OptionDescription
--env <environment>environment name or ID
--threads <n>number of PHP threads
--memory <mb>memory per PHP thread in MB
--dry-runprint the resolved target and request; change nothing
--no-waitreturn the operation ID instead of waiting
--timeout <minutes>give up waiting after this many minutes (default 30)

Global options --profile, --json and --no-input apply too. See scripting and CI.

Kinsta API: GET /sites, POST /sites/environments/{env_id}/change-environment-php-allocation

This is only for premium staging environments. The allocation of the live and the standard staging environment is changed per site with sites php-allocation.

Change the webroot subfolder of an environment.

Terminal window
kinstactl env webroot my-site /public --env live
kinstactl env webroot <site> <subfolder> [options]

Change the webroot subfolder of an environment

Arguments

ArgumentDescription
sitesite name, display name or ID
subfolderwebroot subfolder, e.g. /public or /

Options

OptionDescription
--env <environment>environment name or ID
--no-clear-cachedo not clear all caches afterwards
--no-refreshdo not refresh the plugin and theme inventory
--dry-runprint the resolved target and request; change nothing
--no-waitreturn the operation ID instead of waiting
--timeout <minutes>give up waiting after this many minutes (default 30)

Global options --profile, --json and --no-input apply too. See scripting and CI.

Kinsta API: GET /sites, POST /sites/environments/{env_id}/change-webroot-subfolder

Use this when the site should be served from a subfolder such as /public. Pass / to serve from the root again. After the change kinstactl clears all caches and refreshes the plugin and theme inventory, unless you pass --no-clear-cache or --no-refresh.

Show the file tree of an environment.

Terminal window
kinstactl env files my-site --env live
kinstactl env files [site] [options]

Show the file tree of an environment

Arguments

ArgumentDescription
sitesite name, display name or ID

Options

OptionDescription
--env <environment>environment name or ID

Global options --profile, --json and --no-input apply too. See scripting and CI.

Kinsta API: GET /sites, GET /sites/environments/{env_id}/file-list

Handy to check which paths exist before you use --path with env push.