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
+38 -5
View File
@@ -8,19 +8,52 @@ RETENTION_DAYS="${BACKUP_RETENTION_DAYS:-14}"
SYNOLOGY_BACKUP_DIR="${SYNOLOGY_BACKUP_DIR:-}"
timestamp="$(date -u +%Y%m%d-%H%M%S)"
backup_file="postgres-${timestamp}.dump"
postgres_file="postgres-${timestamp}.dump"
uploads_file="uploads-${timestamp}.tar.gz"
config_file="config-${timestamp}.tar.gz"
manifest_file="backup-${timestamp}.manifest"
mkdir -p "${BACKUP_DIR}"
docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" exec -T postgres sh -lc \
"PGPASSWORD=\"\$POSTGRES_PASSWORD\" pg_dump -U \"\$POSTGRES_USER\" -d \"\$POSTGRES_DB\" -Fc" \
> "${BACKUP_DIR}/${backup_file}"
> "${BACKUP_DIR}/${postgres_file}"
find "${BACKUP_DIR}" -type f -name 'postgres-*.dump' -mtime +"${RETENTION_DAYS}" -delete
docker compose --env-file "${ENV_FILE}" -f "${COMPOSE_FILE}" run --rm --no-deps --entrypoint sh app -lc \
"tar -C /app/uploads -czf - ." \
> "${BACKUP_DIR}/${uploads_file}"
tar -C . -czf "${BACKUP_DIR}/${config_file}" \
"${ENV_FILE}" \
"${COMPOSE_FILE}" \
deploy/cloudflared/config.yml
cat > "${BACKUP_DIR}/${manifest_file}" <<EOF
created_at_utc=${timestamp}
postgres_dump=${postgres_file}
uploads_archive=${uploads_file}
config_archive=${config_file}
compose_file=${COMPOSE_FILE}
env_file=${ENV_FILE}
EOF
find "${BACKUP_DIR}" -type f \( \
-name 'postgres-*.dump' -o \
-name 'uploads-*.tar.gz' -o \
-name 'config-*.tar.gz' -o \
-name 'backup-*.manifest' \
\) -mtime +"${RETENTION_DAYS}" -delete
if [ -n "${SYNOLOGY_BACKUP_DIR}" ]; then
mkdir -p "${SYNOLOGY_BACKUP_DIR}"
cp "${BACKUP_DIR}/${backup_file}" "${SYNOLOGY_BACKUP_DIR}/${backup_file}"
cp "${BACKUP_DIR}/${postgres_file}" "${SYNOLOGY_BACKUP_DIR}/${postgres_file}"
cp "${BACKUP_DIR}/${uploads_file}" "${SYNOLOGY_BACKUP_DIR}/${uploads_file}"
cp "${BACKUP_DIR}/${config_file}" "${SYNOLOGY_BACKUP_DIR}/${config_file}"
cp "${BACKUP_DIR}/${manifest_file}" "${SYNOLOGY_BACKUP_DIR}/${manifest_file}"
fi
echo "Created backup: ${BACKUP_DIR}/${backup_file}"
echo "Created backup set:"
echo " ${BACKUP_DIR}/${postgres_file}"
echo " ${BACKUP_DIR}/${uploads_file}"
echo " ${BACKUP_DIR}/${config_file}"
echo " ${BACKUP_DIR}/${manifest_file}"