Skip to content

Script Parameters

Script parameters let one script be reused across repositories without hard-coding every value.

Borg UI detects Bash-style placeholders:

bash
${PARAM}
${PARAM:-default}

Parameter names must be uppercase snake case:

text
DB_HOST
DB_PASSWORD
API_TOKEN
BACKUP_DIR

Required vs Optional

Required:

bash
pg_dump -h "${DB_HOST}" -U "${DB_USER}" "${DB_NAME}"

Optional with default:

bash
BACKUP_DIR="${BACKUP_DIR:-/tmp/borg-ui-dumps}"

If a default exists, Borg UI treats the parameter as optional.

Secret Detection

Parameters with these suffixes are treated as password fields:

  • _PASSWORD
  • _TOKEN
  • _SECRET
  • _KEY
  • _API_KEY
  • _PASSPHRASE
  • _APIKEY
  • _AUTH
  • _CREDENTIAL
  • _CREDENTIALS

Example:

bash
curl -H "Authorization: Bearer ${API_TOKEN}" "${ENDPOINT_URL}"

API_TOKEN is shown as a secret field.

Reserved Variables

Variables starting with BORG_UI_ are reserved and injected by Borg UI at runtime.

Do not define parameters with this prefix.

Injected variables include:

VariableMeaning
BORG_UI_HOOK_TYPEpre-backup or post-backup
BORG_UI_BACKUP_STATUSpost-backup result
BORG_UI_REPOSITORY_IDrepository ID
BORG_UI_REPOSITORY_NAMErepository name
BORG_UI_REPOSITORY_PATHrepository path
BORG_UI_JOB_IDbackup job ID
BORG_UI_REMOTE_HOSTremote source host for script library execution and script tests, when available
BORG_UI_REMOTE_PORTremote source SSH port for script library execution and script tests
BORG_UI_REMOTE_USERNAMEremote source username for script library execution and script tests
BORG_UI_SOURCE_HOSTremote source host for legacy inline repository hooks, when available
BORG_UI_SOURCE_PORTremote source SSH port for legacy inline repository hooks
BORG_UI_SOURCE_USERNAMEremote source username for legacy inline repository hooks

If a script must work in both paths, read REMOTE first and fall back to SOURCE:

bash
remote_host="${BORG_UI_REMOTE_HOST:-${BORG_UI_SOURCE_HOST:-}}"
remote_port="${BORG_UI_REMOTE_PORT:-${BORG_UI_SOURCE_PORT:-22}}"
remote_user="${BORG_UI_REMOTE_USERNAME:-${BORG_UI_SOURCE_USERNAME:-}}"

Example

bash
#!/usr/bin/env bash
set -euo pipefail

dump_dir="${DUMP_DIR:-/local/db-dumps}"
mkdir -p "$dump_dir"

mysqldump \
  -h "${DB_HOST}" \
  -P "${DB_PORT:-3306}" \
  -u "${DB_USER}" \
  -p"${DB_PASSWORD}" \
  "${DB_NAME}" > "$dump_dir/${DB_NAME}.sql"

Detected parameters:

ParameterRequiredType
DB_HOSTyestext
DB_PORTnotext
DB_USERyestext
DB_PASSWORDyespassword
DB_NAMEyestext
DUMP_DIRnotext

Safety

Parameter values are passed as environment variables to the script process. They are not interpolated into a shell command by Borg UI.

Your script is still responsible for quoting variables correctly:

bash
"${DB_NAME}"

not:

bash
$DB_NAME

Distributed under the AGPL-3.0 License.