---
title: Using Hosty CLI
slug: hosty/using-hosty-cli
createdAt: 2026-11-08T11:27:49.710Z
---

This page lists the commands of Hosty CLI and the options you'll use most. To set it up, see [Setting up Hosty CLI](https://wiki.systemseed.com/hosty/setting-up-hosty-cli). The examples run `hosty <command>`: with the helper script from the setup, that is `./hosty.sh <command>`.

For all options of a command, add `--help`:

```bash
hosty deploy --help
```

:::hint{type="info"}
Hosty CLI can do only what your [role](https://wiki.systemseed.com/hosty/roles-and-permissions) allows. For example, developers don't see production at all, and only release managers (CI) build and deploy.
:::

## Commands

| Command                    | Short name | What it does                                            | Needs |
| -------------------------- | ---------- | ------------------------------------------------------- | ----- |
| `authenticate`             | `auth`     | Starts a 12-hour session with two-factor authentication |       |
| `environment:list`         | `ls`       | Lists the environments of the project                   | VPN   |
| `environment:domains`      | `domains`  | Lists the domains of an environment                     | VPN   |
| `environment:logs`         | `logs`     | Shows the logs of an application                        | VPN   |
| `environment:shell`        | `sh`       | Opens a shell in a container                            | VPN   |
| `environment:exec`         | `exec`     | Runs a command in a container                           | VPN   |
| `environment:run`          | `run`      | Runs a command in a pod of its own                      | VPN   |
| `environment:copy`         | `cp`       | Copies files between your computer and an environment   | VPN   |
| `environment:build`        | `build`    | Builds the images of the applications and pushes them   |       |
| `environment:deploy`       | `deploy`   | Creates or updates an environment                       | VPN   |
| `environment:delete`       | `delete`   | Deletes a development environment                       | VPN   |
| `backup:create`            |            | Backs up production now                                 | VPN   |
| `backup:database:list`     |            | Lists the database backups                              | MFA   |
| `backup:database:download` |            | Downloads a database backup                             | MFA   |
| `backup:database:upload`   |            | Uploads a database backup                               | MFA   |
| `backup:files:download`    |            | Downloads the files backup of a storage                 | MFA   |
| `backup:files:upload`      |            | Uploads files to the backup of a storage                | MFA   |

**VPN** means that the command talks to the cluster, which is usually reachable only through the VPN (see [Setting up a new user](https://wiki.systemseed.com/hosty/setting-up-a-new-user)). **MFA** means that the command needs a session of `hosty auth`. If you don't have one, the command asks for a code from your authenticator app.

## Common options

- **Environment.** Most commands take the name of the environment as the first argument, i.e. `hosty logs stage`. See [Working with environments](https://wiki.systemseed.com/hosty/working-with-environments) for the names.
- **`--application`, `-a`.** The application to work with. You need it only when the project has more than one application, i.e. `--application=backend`.
- **`--container`, `-c`.** The container to work with in `logs`, `sh`, `exec` and `cp`. By default, it's the main container of the application: `php`, `node` or `python`. Use `--container=nginx` or `--container=apache` for the web server.
- **Verbosity.** Commands print only the main messages by default. Add `-v` to see the progress of the command, or `-vvv` to see everything it does, for debugging.

## Environments

List the environments of the project:

```bash
hosty ls
```

Developers see only the development environments. The output is the names separated by spaces, so that scripts can read it. Add `-v` for a list.

List the domains of an environment:

```bash
hosty domains stage
hosty domains production --application=backend
```

## Logs

```bash
hosty logs stage
```

The command shows the logs of all pods of the application, sorted by time, each line with the name of its pod. To follow new lines as they come, add `--watch` (`-w`). For the logs of the web server, add `--container=nginx`.

Logs are kept only as long as the pod runs: a deployment or a restart starts with empty logs.

## Shell

Open a shell in the main container of the application:

```bash
hosty sh stage
hosty sh production --application=backend --container=nginx
```

The shell opens in the newest pod that is ready. The code of PHP and Node.js applications is read-only there (see Read-only code below).

## Running commands

There are two ways to run a command on an environment.

### `exec`: a quick command in a running container

```bash
hosty exec stage --command="drush status"
```

The command runs in the newest ready pod of the application, like in its shell. Repeat `--command` to run several commands one after another; the first one that fails stops the rest:

```bash
hosty exec stage --command="drush updb -y" --command="drush cr"
```

Add `--no-tty` when you read the output in a script or run the command in CI without a terminal.

### `run`: a longer command in a pod of its own

```bash
hosty run production -- drush cim -y
hosty run production -- "drush updb -y && drush cr"
```

The command runs in a new pod with the same image and settings as the cron jobs of the application, on the development nodes, so it doesn't take resources from the site. Hosty CLI shows its output and exits with its exit code. Put the command after `--`. A single quoted command runs in the shell as it is, with `&&` and pipes.

Use `run` for imports, migrations and other long tasks:

- The run goes on in the cluster when you press Ctrl+C or lose the connection. Hosty CLI tells you how to follow it and how to stop it.
- It stops after an hour. Set another limit in seconds with `--timeout`, up to a day (`86400`).
- It gets 256 MiB of memory. Ask for more with `--memory`, in MiB, up to the memory limit of the application.
- `--detach` only starts the run, without waiting for it.
- A run that fails isn't started again, and finished runs are deleted with their output after a day.

## Copying files

Copy a file or a folder between your computer and an environment:

```bash
hosty cp production hosty://web/sites/default/files/logo.png ./logo.png
hosty cp stage ./import hosty://web/sites/default/files/import
```

Paths on your computer are relative to the root of the project. Paths on the environment start with `hosty://` and are relative to the root of the application in the container: `/var/www/html` for PHP, `/usr/src/app` for Node.js and Python. One side must be local and the other remote.

### Read-only code

The code of PHP and Node.js applications is read-only on the environments, so you can't change it or copy files into it. Only the persistent storages from `hosty.yaml` are writable. An application that must write into its code at runtime turns this off with `readOnlyCode: false` (see [Project configuration](https://wiki.systemseed.com/hosty/project-configuration)).

## Building and deploying

Release managers, that is CI, build and deploy the environments. See [Working with environments](https://wiki.systemseed.com/hosty/working-with-environments) and [CI/CD configuration](https://wiki.systemseed.com/hosty/cicd-configuration).

```bash
hosty build --push stage
hosty deploy stage
```

`build` builds the images of all applications of the project (or one with `--application`) and, with `--push` (`-p`), pushes them to Hosty. It builds only the images that don't exist yet, as the tag of an image depends on the last commit of its code. Commit your changes first: a build doesn't see changes that aren't committed. With `--exists` (`-e`), the command only checks whether the images exist and fails if any is missing, which tells CI whether it has to install the dependencies at all.

`deploy` creates the environment, or updates it if it exists. The images must be pushed first. The first deployment imports the backups and waits for the import up to `import.timeout` minutes from `hosty.yaml` (30 by default).

## Deleting a development environment

```bash
hosty delete stage
```

The environment is deleted with its database and files, for good. Hosty CLI asks for a confirmation in a terminal; `--yes` (`-y`) skips the question. In CI, without a terminal, it doesn't ask.

Production can't be deleted with Hosty CLI. Only the admins can delete it.

## Backups

Backups are made from production only. For how development environments use them, see [Working with environments](https://wiki.systemseed.com/hosty/working-with-environments).

If the project has several applications, add `--application` to all backup commands. If an application uses the database of another one, use the backups of that other application.

### Back up production now

```bash
hosty backup:create
```

The command backs up the database and the files of production with the same job as the scheduled backups, and waits for it (up to an hour). Add `--no-wait` to only start it.

### Database backups

There are two kinds of database backups:

- **full**: the whole database. Only lead developers can download it.
- **partial**: the same database without the data of the tables listed in `excludeTablesFromImportOnDevEnvs` in `hosty.yaml`, i.e. personal data and caches. Development environments are created from it.

List the latest backups (50 by default, change it with `--limit`):

```bash
hosty backup:database:list --partial
```

Download the latest backup, or a particular one with `--name`. The path is relative to the root of the project:

```bash
hosty backup:database:download --partial ./dump.sql.zst
hosty backup:database:download --full --name=2026-10-24T08:00:12Z-full.sql.zst ./dump.sql.zst
```

Backups made by Hosty are compressed with zstd (`.sql.zst`). Older ones may be gzipped (`.sql.gz`).

Upload a database backup (lead developers only):

```bash
hosty backup:database:upload --full ./backup.sql.gz
```

Supported formats are `.sql`, `.sql.gz` (or `.gz`, `.gzip`) and `.sql.zst` (or `.zst`). Archives such as `.tar.gz` aren't. The upload becomes the latest backup, so the next new environment imports it.

### Files backups

Each persistent storage from `hosty.yaml` has a backup of its own. Download the backup of a storage into a folder of the project:

```bash
hosty backup:files:download public web/sites/default/files
hosty backup:files:download public web/sites/default/files --exclude="styles/*" --exclude="css/*"
```

The download makes the folder the same as the backup: it also deletes the local files that the backup doesn't have. Hosty CLI shows how many files it would download and delete, and asks before it deletes anything; `--yes` (`-y`) skips the question. `--exclude` (`-e`) and `--include` (`-i`) take paths relative to the root of the storage.

Upload files to the backup of a storage (lead developers only):

```bash
hosty backup:files:upload public web/sites/default/files/
```

:::hint{type="warning"}
The upload makes the backup the same as your folder: files of the backup that your folder doesn't have are deleted. Hosty CLI shows how many files it would upload and delete and asks for a confirmation (`--yes` skips it, and CI needs it). It refuses a folder that doesn't exist or is empty.
:::
