Skip to main content

sentinel backup

Runs a database backup from a YAML configuration file or from CLI flags, and groups the subcommands that inspect, verify, and compare the resulting artifacts.

Synopsis

sentinel backup [flags]
sentinel backup [command]

When --config resolves to a valid configuration, every enabled job in databases: runs and all other CLI flags act as per-run overrides. When --config is omitted and the configuration cannot be loaded, --type selects a single ad-hoc job built entirely from flags.

Subcommands

SubcommandPurpose
verifyRe-computes the SHA-256 fingerprint of a stored artifact and compares it against the manifest value. Takes one [backup-id], or --all for a repository-wide sweep.
chain-statusPrints the active chain ID, chain index, chain depth, latest backup type, and last success time for one configured job.
chain-listLists the successful backup executions belonging to one incremental chain ID, ordered by chain index.
force-fullRuns a full backup immediately for a configured job and resets its incremental chain state.
diffCompares the recorded metadata of two backups and flags silent security regressions.

Flags

sentinel backup

FlagTypeDefaultDescription
--argsstringn/aExtra arguments appended to the underlying dump command. Overrides additional_args from the config when set.
--aws-access-key-idstringn/aAWS access key ID for the S3 backend.
--aws-bucketstringn/aAWS S3 bucket name.
--aws-bucket-endpointstringn/aS3 endpoint URL. Set this for S3-compatible services such as MinIO.
--aws-regionstringus-east-1AWS region.
--aws-secretstringn/aAWS secret access key.
-c, --compressboolfalseCompress the backup. Applies to PostgreSQL (maps to compress) and MongoDB (maps to gzip); ignored by MySQL and MariaDB.
--configstringn/aPath to the YAML configuration file. The preferred mode of operation.
-d, --databasestringn/aDatabase name. * in the config triggers auto-discovery.
--gcs-bucketstringn/aGoogle Cloud Storage bucket name. Required when --storage gcs.
--gcs-credentials-filestringn/aPath to the Google Cloud service account key file.
--gcs-project-idstringn/aGoogle Cloud project ID. Optional.
--gdrive-folder-idstringn/aGoogle Drive folder ID. Required when --storage google-drive.
--gdrive-sa-filestringn/aPath to the Google Drive service account file. Required when --storage google-drive.
-h, --helpboolfalsePrint help for backup.
-H, --hoststring127.0.0.1Database host.
--local-pathstringn/aDirectory the artifact is written to when --storage local.
-o, --outputstringn/aOutput artifact name. Scheduled runs append a job name and timestamp to it.
--password-envstringn/aName of the environment variable holding the database password.
--password-filestringn/aPath to a file whose first line is the database password. A group- or world-readable file produces a permissions warning on stderr.
--pg-compression-algostringn/aPostgreSQL compression algorithm: gzip, lz4, zstd, or none.
--pg-compression-levelint1PostgreSQL compression level, 19.
--pg-out-formatstringn/aPostgreSQL output format: p (plain), c (custom), d (directory), or t (tar).
-P, --portstringn/aDatabase port. Must parse as an integer when overriding a configured job.
-s, --storagestringlocalStorage backend: local, s3, gcs, or google-drive.
-t, --typestringn/aDatabase engine: mysql, postgres, mariadb, or mongodb.
--uristringmongodb://localhost:27017MongoDB connection URI.
-u, --userstringrootDatabase user.
warning
No --password flag

There is no supported flag for passing a password on the command line. Use --password-env, --password-file, or databases.<id>.password_env in the configuration file. A password in argv is visible via ps, /proc/<pid>/cmdline, and shell history.

sentinel backup verify [backup-id]

Accepts at most one positional backup-id. Exactly one of <backup-id> or --all must be supplied.

FlagTypeDefaultDescription
--allboolfalseVerify every recorded successful backup and emit an aggregate report plus a single exit code. Mutually exclusive with a positional backup-id.
--allow-legacy-envelopeboolfalse, or true when SENTINEL_ALLOW_LEGACY_ENVELOPE is 1/true/yesDecrypt artifacts written before the v2 encryption envelope. Unsafe: pre-v2 streams used a flawed nonce scheme. Use only to recover plaintext for re-encryption.
--configstring$HOME/.sentinel/config.yamlPath to the Sentinel YAML config. Supplies the history database path and the storage credentials used to fetch remote artifacts.
-h, --helpboolfalsePrint help for verify.
--ignore-missing-manifestboolfalseWith --all: treat a missing_manifest result as a warning (exit 0) rather than an integrity failure.
--jobstringn/aWith --all: restrict the sweep to a single named backup job.
--outputstringinherits log_format from the configOutput format: json or text.
--sincestringn/aWith --all: only verify backups newer than this age. Accepts 30d, 4w, or any Go duration such as 720h.

Each verified backup is classified as ok, corrupted, missing_artifact, or missing_manifest. Artifacts on s3, gcs, azure, or google-drive are downloaded with their <key>.manifest.json sidecar to a temporary directory, verified there, and the directory is removed before the command returns.

Exit codes: 0 success, 2 backup ID not found, 3 verification skipped (no manifest), 4 operational failure (config, history database, listing), 5 at least one real integrity failure during an --all sweep.

sentinel backup chain-status

FlagTypeDefaultDescription
-h, --helpboolfalsePrint help for chain-status.
--jobstringn/aConfigured backup job name. Required.

sentinel backup chain-list

FlagTypeDefaultDescription
--chain-idstringn/aIncremental chain ID to list. Required.
-h, --helpboolfalsePrint help for chain-list.

sentinel backup force-full

FlagTypeDefaultDescription
-h, --helpboolfalsePrint help for force-full.
--jobstringn/aConfigured backup job name. Required.
caution
chain-status, chain-list, and force-full require a config they cannot receive

All three handlers reject the run with Error: --config is required, but none of them registers a --config flag and backup's own --config is a local flag rather than a persistent one, so passing --config returns Error: unknown flag: --config. As of v1.4.0 these three subcommands cannot complete. Use sentinel monitor to inspect chain metadata in the meantime.

sentinel backup diff <id1> <id2>

Requires exactly two positional backup IDs.

FlagTypeDefaultDescription
--configstring$HOME/.sentinel/config.yamlPath to the Sentinel YAML config.
-h, --helpboolfalsePrint help for diff.
--outputstringinherits log_format from the configOutput format: json or text.

diff reads only the monitor row and the <artifact>.manifest.json sidecar for each ID; no artifact bytes are read. Security regressions; encryption turned off, a hash-algorithm change, an encryption-parameter downgrade; exit non-zero (1). Size and duration swings of 50% or more are marked with a warning symbol and remain exit 0.

Examples

Run every enabled job in a configuration file:

sentinel backup --config sentinel.yaml

Each job prints its own progress; retention output follows for jobs with a retention policy. A non-zero exit means at least one job failed.

Run a single ad-hoc PostgreSQL backup to a local directory, reading the password from the environment:

export PGPASSWORD_FOR_SENTINEL='<from-your-secret-store>'
sentinel backup \
--type postgres --host db.internal --port 5432 \
--user backup_operator --database app \
--password-env PGPASSWORD_FOR_SENTINEL \
--storage local --local-path /var/backups/sentinel \
--pg-out-format c --compress

A custom-format dump appears under /var/backups/sentinel alongside its .manifest.json sidecar.

Back up to an S3-compatible endpoint:

sentinel backup --config sentinel.yaml \
--storage s3 --aws-bucket sentinel-backups \
--aws-region eu-west-3 --aws-bucket-endpoint https://minio.internal:9000

The flags override the configured storage block for this run only; the config file is not modified.

Verify one recorded backup:

sentinel backup verify 01HQ8Z3K4M5N6P7Q8R9S --config sentinel.yaml

Prints the stored and computed SHA-256 values. Exit 0 means they match.

Sweep the whole repository for the last 30 days as JSON, for a cron or CI gate:

sentinel backup verify --all --since 30d --output json --config sentinel.yaml

Emits one JSON record per backup with status and hash_match. Exit 5 means at least one backup is corrupted or its artifact is missing.

Compare two backups of the same job to catch a silent security regression:

sentinel backup diff 01HQ8Z3K4M5N6P7Q8R9S 01HQ9A1B2C3D4E5F6G7H --config sentinel.yaml

Prints a table of differing fields. A non-zero exit means encryption or hashing weakened between the two runs.

{/* sources: internal/cli/backup.go, internal/cli/backup_verify.go, internal/cli/backup_diff.go, internal/cli/exit_codes.go, internal/cli/legacy_envelope.go, internal/config/since.go, internal/adapters/storage/validation.go */}