For developers

Using Hosty CLI

28min



Hosty CLI respects user permissions documented in Roles & Permissions. It means that certain users may not have access to certain commands or environments. For example, users with "developer" role can't access any resource related to production environments. Another example: users with "release manager" role can not access backups.

Verbosity levels

CLI supports 3 verbosity modes for every command:

  • Normal: prints most important messages. Default verbosity mode.
  • Verbose: prints more information about the command execution progress when -vflag is added to a command.
  • Very, Very Verbose: prints exessive logs during the command execution, used mainly for debugging purpose. Add -vvv to a command.

How to get a list of available commands?

Shell


How to access application logs?

This command requires VPN connection to the cluster.

Run the following command:

Shell


Or use a shorthand:

Shell


If you have more than one application configured, pass --application flag with the name of the application you need the logs for:

Shell


By default, the command prints logs from the primary container (i.e. php, node or python). If you need to get logs from another container, i.e. nginx, then use --containerflag:

Shell


How to download database backup?

This command requires two-factor authentication.

To downloads the latest database backup without personal identifiable information to the local environment run:

Shell


To download full database backup (only lead developers have permission for it):

Shell


To download a database backup from a specific date and time, first print the list of available backup names:

Shell


Then, use --name flag to download the selected backup:

Shell


How to download files backup?

This command requires two-factor authentication.

To downloads the latest files backup, run the following command:

Shell

  • <storageName> is the name of persistent storage from your hosty.yaml file
  • <targetPath> is the path where to sync the files, relative to the project root

If you want to exclude certain folder from sync, use --excludeflag:

Shell


How to access environment console?

This command requires VPN connection to the cluster.

To open the console of the environment, run the following command:

Shell


Or use a shorthand:

Shell


For example:

Shell


To open the console of a particular application (if you have more than 1 application configured for the project):

Shell


To open the console of a particular container (i.e. nginx):

Shell


How to execute a command in an environment?

This command requires VPN connection to the cluster.

To execute a command in the remote environment, run the following command:

Shell


Or use a shorthand:

Shell


For example:

Shell


To execute a command for a particular application (if you have more than 1 application configured for the project):

Shell


To execute a command inside of a particular container (i.e. nginx):

Shell


How to get a list of available environments?

This command requires VPN connection to the cluster.

To print the list of all deployed environments, run:

Shell


Note that users with developer role will not see a "production" environment in the list, because they don't have access to it. See Roles & Permissions for more details.

How to get URLs assigned to an environment?

This command requires VPN connection to the cluster.

To get a list of the environment URLs, run:

Shell


Or use a shorthand:

Shell


For example:

Shell


To get a domains only for a particular application (if you have more than one application configured for the project):

Shell


How to copy files between local and remote environments?

This command requires VPN connection to the cluster.

For security reasons, remote environments are read-only (apart from persistent storages defined in hosty.yaml file), so if you want to upload files to a remote environment make sure to use one of the persistent storage locations, otherwise the command will fail.

To copy files or folders between local and remove environments, use the following command:

Shell


Or use a shorthand:

Shell

  • <environmentName> is the name of the remove environment
  • <from> and <to> are paths from/to copy the files. For local paths use path relative to the project root. For remote paths use path starting with hosty://which will be relative to the project root on a remote environment

For example:

Shell