Root cause of a real production failure on the first live install
(wap-proxy, 2026-07-25): DB_PASSWORD was generated with
`openssl rand -base64 24`, which can produce '/', '+', or '=' --
docker-compose.yml then naively interpolated the raw password into
postgres://postgres:${DB_PASSWORD}@db:5432/..., and a generated
password containing '/' broke the connection string outright. The API
never became healthy; log ingestion failed completely.
- install.sh now generates with `openssl rand -hex 32` (always
[0-9a-f], can't produce this class of character). Same fix applied
everywhere else openssl-rand-base64-24 was referenced.
- docker-compose.yml no longer builds DATABASE_URL by string
interpolation -- DB_PASSWORD is passed as its own var and the API
assembles the connection string safely internally using
net/url.UserPassword (proper percent-encoding), a second,
independent layer so the installer doesn't rely on the password
generator alone. See the matching argus-appliance commit for the
Go-side change and its regression test.
- backup.sh/healthcheck.sh/restore.sh/uninstall.sh still defaulted
ARGUS_INSTALL_DIR to $HOME/argus, inconsistent with install.sh/
update.sh's own /opt/argus default (changed in an earlier commit
this session) -- confirmed live on the same install: healthcheck.sh
and uninstall.sh reported "no installation found" when run from the
real, correct directory. All five scripts now agree on /opt/argus.
Corresponding argus-appliance fix (config.go's buildDatabaseURL, v3.73.1)
already built and pushed to git-cloud.weboria.eu/weboria/argus-api.
54 lines
2.0 KiB
Bash
Executable File
54 lines
2.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
#
|
|
# ARGUS restore — loads a backup created by backup.sh into a FRESH ARGUS
|
|
# installation (empty database, no prior data). To restore onto a machine
|
|
# that already has data on it, uninstall.sh --remove-data && install.sh
|
|
# first, then run this.
|
|
#
|
|
# cd /opt/argus && ./restore.sh argus-backup-20260719-120000.tar.gz
|
|
#
|
|
set -euo pipefail
|
|
|
|
INSTALL_DIR="${ARGUS_INSTALL_DIR:-/opt/argus}"
|
|
ARCHIVE="${1:-}"
|
|
|
|
bold() { printf '\033[1m%s\033[0m\n' "$1"; }
|
|
info() { printf ' %s\n' "$1"; }
|
|
ok() { printf ' \033[32m✓\033[0m %s\n' "$1"; }
|
|
warn() { printf ' \033[33m!\033[0m %s\n' "$1"; }
|
|
fail() { printf ' \033[31m✗\033[0m %s\n' "$1" >&2; exit 1; }
|
|
|
|
[ -n "$ARCHIVE" ] || fail "Usage: ./restore.sh <path-to-backup.tar.gz>"
|
|
[ -f "$ARCHIVE" ] || fail "No such file: $ARCHIVE"
|
|
[ -f "$INSTALL_DIR/docker-compose.yml" ] || fail "No ARGUS installation found at $INSTALL_DIR (set ARGUS_INSTALL_DIR if you installed elsewhere)."
|
|
cd "$INSTALL_DIR"
|
|
|
|
warn "This assumes a freshly installed, empty ARGUS instance."
|
|
warn "Restoring onto an instance that already has data will fail or corrupt it."
|
|
printf " Type YES to continue: "
|
|
read -r CONFIRM
|
|
[ "$CONFIRM" = "YES" ] || fail "Aborted."
|
|
|
|
WORKDIR="$(mktemp -d)"
|
|
trap 'rm -rf "$WORKDIR"' EXIT
|
|
tar xzf "$ARCHIVE" -C "$WORKDIR"
|
|
[ -f "$WORKDIR/db.sql.gz" ] && [ -f "$WORKDIR/api-data.tar.gz" ] || fail "Not a valid ARGUS backup archive (missing db.sql.gz / api-data.tar.gz)."
|
|
|
|
bold "Stopping the API (keeping the database up)..."
|
|
docker compose stop api ui nginx >/dev/null
|
|
|
|
bold "Restoring database..."
|
|
gunzip -c "$WORKDIR/db.sql.gz" | docker compose exec -T db psql -U postgres argus >/dev/null
|
|
ok "Database restored"
|
|
|
|
bold "Restoring application data..."
|
|
docker run --rm -v argus_api_data:/data -v "$WORKDIR":/backup alpine \
|
|
sh -c "rm -rf /data/* && tar xzf /backup/api-data.tar.gz -C /data" >/dev/null 2>&1
|
|
ok "Application data restored"
|
|
|
|
bold "Starting ARGUS..."
|
|
docker compose up -d
|
|
echo
|
|
ok "Restore complete"
|
|
info "Give it a minute to finish starting, then check: ./healthcheck.sh"
|