Update backup script to include everything needed to do a bare metal restore of the new V6 server
Quality Gate / gate (push) Failing after 49s

This commit is contained in:
Jim Lancaster
2026-08-26 12:21:40 -05:00
parent 2c6ef46f5f
commit 89ed83239e
5 changed files with 88 additions and 14 deletions
+31
View File
@@ -15,6 +15,22 @@ if [ ! -f "${dump_file}" ]; then
exit 1
fi
backup_dir="$(dirname "${dump_file}")"
backup_name="$(basename "${dump_file}")"
timestamp="$(printf '%s' "${backup_name}" | sed -n 's/^postgres-\([0-9]\{8\}-[0-9]\{6\}\)\.dump$/\1/p')"
uploads_file=""
config_file=""
if [ -n "${timestamp}" ]; then
candidate_uploads="${backup_dir}/uploads-${timestamp}.tar.gz"
candidate_config="${backup_dir}/config-${timestamp}.tar.gz"
if [ -f "${candidate_uploads}" ]; then
uploads_file="${candidate_uploads}"
fi
if [ -f "${candidate_config}" ]; then
config_file="${candidate_config}"
fi
fi
docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" exec -T postgres sh -lc \
"PGPASSWORD=\"\$POSTGRES_PASSWORD\" psql -U \"\$POSTGRES_USER\" -d postgres -c \"DROP DATABASE IF EXISTS \\\"\$POSTGRES_DB\\\";\""
@@ -24,4 +40,19 @@ docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" exec -T postgres sh
cat "${dump_file}" | docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" exec -T postgres sh -lc \
"PGPASSWORD=\"\$POSTGRES_PASSWORD\" pg_restore -U \"\$POSTGRES_USER\" -d \"\$POSTGRES_DB\" --clean --if-exists --no-owner --no-privileges"
if [ -n "${uploads_file}" ]; then
cat "${uploads_file}" | docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" run --rm --no-deps --entrypoint sh app -lc \
"mkdir -p /app/uploads && find /app/uploads -mindepth 1 -delete && tar -xzf - -C /app/uploads"
fi
if [ -n "${config_file}" ]; then
tar -xzf "${config_file}" -C .
fi
echo "Restore complete from: ${dump_file}"
if [ -n "${uploads_file}" ]; then
echo "Restored uploads archive: ${uploads_file}"
fi
if [ -n "${config_file}" ]; then
echo "Restored config archive: ${config_file}"
fi