Using Zerops Setup Control (zsc)
Zerops Setup Control (zsc) is a command-line utility automatically installed in all Zerops containers enabling developers to manage and control container environments directly from within both runtime and build contexts.
Zerops Setup Control provides essential capabilities for container management, including resource scaling, technology installation, and environment configuration.
Zerops Setup Control commands can be executed in two ways:
- Manual execution:
- From the web terminal interface in Zerops GUI
- Using SSH connections to your containers
- Automated execution:
- As part of your
zerops.yaml
configuration file
- As part of your
Usage
Commands
help
This command lists available commands and flags on a command by placing help
, -h
or --help
flag after the command.
completion
Generate the autocompletion script for zsc for the specified shell.
Available sub-commands
bash
: Generate the autocompletion script for bashfish
: Generate the autocompletion script for fishpowershell
: Generate the autocompletion script for powershellzsh
: Generate the autocompletion script for zsh
Available flags
-h, --help
: Help for the completion command
backup-create
Creates a backup of any specified stack in your project.
Required parameters
<stackName>
: Name of the stack to backup
Available flags
-h, --help
: Help for the backup-create command
Example
cdn
Manages CDN (Content Delivery Network) operations for your Zerops services.
Available sub-commands
purge
: Invalidates cached content from the CDN for a specific domain. The purge command allows you to ensure that the most up-to-date content is being served to visitors after making updates to your site.
Available flags
-h, --help
: Help for the cdn command
Examples
# Purge all CDN cache for a specific domain
zsc cdn purge example.com
# Purge all content using wildcard pattern
zsc cdn purge example.com "/*"
# Purge CDN cache for a specific file (note the $ suffix)
zsc cdn purge example.com "/path/to/my-file$"
# Purge CDN cache for a specific directory
zsc cdn purge example.com "/images/"
- This command must be executed in any container within the project that has the CDN-enabled domain active
- Currently, the purge command only works for the Static Mode CDN
crontab
Manages scheduled tasks that are defined in your zerops.yaml configuration.
Available sub-commands
list
: List all crontabs defined in zerops.yamlrun
: Execute crontab command defined in zerops.yaml
Available flags
-h, --help
: Help for the crontab command
execOnce
Execute a command exactly once across all containers in a service, preventing duplicate execution in high-availability setups.
Required parameters
<key>
: A unique identifier for the execution--
: Standard separator indicating the end of options and beginning of the command<command> [args...]
: The actual command to execute and its arguments
Available flags
-r, --retryUntilSuccessful
: Retry command until it succeeds-v, --verbose
: Verbose output-h, --help
: Help for the execOnce command
Behavior
- On success: All containers proceed with their tasks
- On failure: All containers report the command as failed
- With --retryUntilSuccessful: The command is retried on a different container until it succeeds
Examples
This command is ideal for database migrations, initialization scripts, and other operations that should only run once in clustered environments.
fail-me
Deliberately fails the current container for testing purposes.
Available flags
-h, --help
: Help for the fail-me command
install
Run install commands for the specified base technology in your runtime container.
Required parameters
<baseName>
: The technology and version to install - see the full list of supported base environments.
Available flags
--buildBase <string>
: Build base (default "php@8.4")--buildOs <string>
: Build os (default "alpine")-m, --mode <string>
: Mode (default "RUNTIME")--runBase <string>
: Run base (default "php-nginx@8.4")--runOs <string>
: Run os (default "alpine")-h, --help
: Help for the install command
Examples
Example usage in zerops.yaml
noop
Keep a container alive indefinitely with a non-terminating process.
Available flags
-s, --silent
: Disables output to StdOut-h, --help
: Help for the noop command
Examples
The noop
command is especially useful for:
- Debugging build failures by keeping containers alive for investigation
- Supporting applications that run as background daemons
- Keeping service containers active when your app doesn't have a foreground process
- As a start command in zerops.yaml for services that don't have a natural blocking command
Usage in zerops.yaml
object-storage
Manages object storage operations for backups and restores.
Available flags
-h, --help
: Help for the object-storage command
When using an object storage service, the command requires the following environment variables to be defined:
objectstorage_apiUrl
- API URL of the object storage serviceobjectstorage_accessKeyId
- Access key ID for authenticationobjectstorage_secretAccessKey
- Secret access key for authenticationobjectstorage_bucketName
- Name of the bucket to use
These environment variables will be automatically available if the object storage service has envIsolation: none
configured, or if the entire project has envIsolation: none
set. Otherwise, you need to explicitly reference these environment variables in your zerops.yaml
file.
Sub-commands
Common parameters
All sub-commands share these parameters:
--storage <string>
: Name of the object storage service--name <string>
: Name of the backup in storage--silent
,-s
: Suppresses command output (default: false)--no-fail
: Prevents command failure with exit code 1 (default: false)
list - Lists all available backups in the specified storage
backup - Creates a backup of specified directories to object storage
Arguments:
<directory>
: One or more directories to back up (at least one required)
Additional options:
--truncate-count <number>
: Number of most recent backups to keep after successful backup (default: 0)-C, --change-directory <directory>
: Change to directory before operation
restore - Restores a backup from object storage to specified or original locations
Arguments:
<directory>
: Directory to restore to. If omitted, files are restored to their original locations
Additional options:
--dryRun
: Simulates restore operation without performing actual changes--overwrite
: Allows overwriting existing files during restore--index <number>
: Specifies which backup to restore. Non-negative values count from newest (0 = newest, 1 = second newest), negative values count from oldest (-1 = oldest, -2 = second oldest) (default: 0)--ignore-non-existing
: Prevents command failure if backup does not exist--strip-components <number>
: Strip NUMBER leading components from file names on extraction
truncate - Removes old backups, keeping only the most recent ones
Additional options:
--dryRun
: Simulates truncate operation without performing actual deletions (default: false)--truncate-count <number>
: Number of most recent backups to keep (default: 5)
Examples
# List all backups
zsc object-storage list --storage objectstorage --name daily-backup
# Create a backup with retention
zsc object-storage backup /var/www --storage objectstorage --name web-backup --truncate-count 5
# Restore with dry run preview
zsc object-storage restore --storage objectstorage --name database-backup --dryRun
# Clean up old backups
zsc object-storage truncate --storage objectstorage --name logs-backup --truncate-count 3
Example usage in zerops.yaml
zerops:
- setup: app
run:
initCommands:
- "zsc object-storage restore --storage objectstorage --name $ZEROPS_StackName --ignore-non-existing ./data/"
crontab:
- timing: "*/10 * * * *"
command: "zsc object-storage backup --storage objectstorage --name $ZEROPS_StackName --truncate-count 5 ./data/"
allContainers: false
resources
Displays the current resource scaling configuration for the container.
Available flags
-h, --help
: Help for the resources command
Example output
Related commands
zsc scale
: Dynamically adjust resource allocations
scale
Dynamically adjust CPU or memory resources for the current container for a specified duration.
Required parameters
cpu|ram
: Resource type to scale (either CPU cores or RAM)<value> <duration>
orauto
: Scale value and duration, or "auto" to disable custom scaling
Available flags
-h, --help
: Help for the scale command
Supported values
- For RAM: Value must be suffixed by a unit (KiB, MiB, GiB); number may be a float.
- For CPU: Value must not be suffixed; number must be an integer.
- "auto": Disables any custom scaling set via this command and must be used without the duration parameter.
- "min" and "max": Set the container to its CURRENT min and max values.
- Numeric values can be prefixed with "+" for relative scaling, adding the requested value to currently used resources.
- Duration must be suffixed by a unit (s = seconds, m = minutes, h = hours, d = days) and cannot be less than 10 minutes.
Examples
- Resource adjustments take effect within approximately 10 seconds
- The container cannot be scaled above or below its max/min resources set in the vertical autoscaling configuration
- If you scale to a value that exceeds the maximum set limit (e.g., 10GB RAM when max is 5GB), the container will only receive the maximum allowed resources
- If service limits are changed while custom scaling is active, the container will automatically adjust to the new boundaries
- If the service auto-scaling configuration is updated, you must call the scale command again to apply custom scaling
If there are insufficient resources on the current server, the container might be moved to another node with available resources, which will reset the scale duration. The container will scale down automatically if resources are not utilized, or if the scale command duration expires.
setSecretEnv
Securely update environment variables containing sensitive information.
Arguments
<key>
: The name of the environment variable to set<content>
: The new value for the variable, or-
to read from stdin
Available flags
-h, --help
: Help for the setSecretEnv command
Examples
Secret environment variables are encrypted at rest and securely distributed to your containers. Use this command for storing sensitive configuration like API keys, tokens, and passwords.
shared-storage
Manages shared storage volumes for persistent data storage.
Available sub-commands
mount
: Mounts the shared storageunmount
: Unmounts the shared storagewait
: Waits for readiness of the storage mount
Available flags
-h, --help
: Help for the shared-storage command
Examples
test
Run diagnostic tests to verify connectivity and service availability.
Required parameters
<host>:<port>
: Host and port to test connectivity to
Available flags
--timeout <duration>
: Maximum test duration (default: 30s)--dialTimeout <duration>
: Single attempt timeout (default: 2s)-4
: Force IPv4-6
: Force IPv6-h, --help
: Help for the test tcp command
Example
version
Displays the current version of Zsc CLI.
Available flags
-h, --help
: Help for the version command