Minor bump — no operator action required (Postgres/ClickHouse changes are automatic). - Postgres: use pgautoupgrade/pgautoupgrade:18-alpine in place of the custom pg_upgrade entrypoint. The existing cluster is upgraded in place automatically on deploy; PGDATA pinned to the legacy path; adds a pg_isready healthcheck. Removes entrypoint.postgres.sh.tmpl and DB_ENTRYPOINT_VERSION. - ClickHouse backup fetch: cache the clickhouse-backup binary on the persistent volume and retry with backoff to avoid the download crash-loop. The tool is required — if it can't be installed after retries the entrypoint aborts and the server does not start, rather than coming up without backup/restore. - Add CLICKHOUSE_DATABASE_URL; bump the clickhouse entrypoint config version. - Remove a stray broken link reference in the README.
This commit is contained in:
@ -1,6 +1,14 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -ex
|
||||
# clickhouse-backup is a backup tool (backupbot pre/post-hooks: `clickhouse-backup create/restore`).
|
||||
# It is a 22 MB GitHub download (rate-limit / network), which can fail to download, and lead to crash loop and download throttling.
|
||||
#
|
||||
# to make the download smoother:
|
||||
# - cache the binary on the persistent clickhouse data volume (/var/lib/clickhouse) so it is fetched
|
||||
# at most once and reused on every container restart (no re-download amplification);
|
||||
# - retry with backoff to ride out transient GitHub failures
|
||||
|
||||
set -e
|
||||
|
||||
CLICKHOUSE_BACKUP_VERSION=2.4.2
|
||||
|
||||
@ -17,13 +25,33 @@ elif [[ $ARCH =~ "x86_64" ]]; then
|
||||
ARCH="amd64"
|
||||
fi
|
||||
|
||||
wget \
|
||||
--quiet \
|
||||
--continue \
|
||||
--no-clobber \
|
||||
--output-document=/tmp/clickhouse-backup.tar.gz \
|
||||
"https://github.com/AlexAkulov/clickhouse-backup/releases/download/v${CLICKHOUSE_BACKUP_VERSION}/clickhouse-backup-linux-${ARCH}.tar.gz" 2>/dev/null
|
||||
CACHE_DIR=/var/lib/clickhouse/.ccci-bin
|
||||
CACHED="${CACHE_DIR}/clickhouse-backup"
|
||||
BIN=/usr/local/bin/clickhouse-backup
|
||||
URL="https://github.com/AlexAkulov/clickhouse-backup/releases/download/v${CLICKHOUSE_BACKUP_VERSION}/clickhouse-backup-linux-${ARCH}.tar.gz"
|
||||
|
||||
tar -xf /tmp/clickhouse-backup.tar.gz --directory=/usr/local/bin --strip-components=3
|
||||
install_clickhouse_backup() {
|
||||
mkdir -p "$CACHE_DIR"
|
||||
if [ -x "$CACHED" ]; then
|
||||
cp -f "$CACHED" "$BIN"
|
||||
echo "clickhouse-backup: restored from persistent cache ($CACHED)"
|
||||
return 0
|
||||
fi
|
||||
for attempt in 1 2 3 4 5; do
|
||||
if wget --continue --output-document=/tmp/clickhouse-backup.tar.gz "$URL" \
|
||||
&& tar -xf /tmp/clickhouse-backup.tar.gz --directory=/usr/local/bin --strip-components=3; then
|
||||
cp -f "$BIN" "$CACHED" 2>/dev/null || true
|
||||
echo "clickhouse-backup: downloaded + cached (attempt ${attempt})"
|
||||
return 0
|
||||
fi
|
||||
echo "clickhouse-backup: fetch attempt ${attempt} failed; backing off $((attempt * 10))s" >&2
|
||||
sleep $((attempt * 10))
|
||||
done
|
||||
echo "clickhouse-backup: fetch FAILED after all retries — aborting; clickhouse-server will NOT start (backup tool is required)" >&2
|
||||
return 1
|
||||
}
|
||||
|
||||
/entrypoint.sh
|
||||
#if the backup tool cannot be installed after retries, it aborts (set -e) so the deploy fails
|
||||
install_clickhouse_backup
|
||||
|
||||
exec /entrypoint.sh
|
||||
|
||||
Reference in New Issue
Block a user