Automation: Final robust DB restore fixes and updated gitignore rules.

This commit is contained in:
Scott Idem
2026-01-12 18:33:05 -05:00
parent 7bd22d1086
commit f886250ae3
15 changed files with 140 additions and 59 deletions

View File

@@ -0,0 +1,20 @@
#!/bin/bash
# Aether Internal Backup Script (Runs inside the Cron Container)
set -e
# These are paths INSIDE the cron container
BACKUP_DIR="/backups"
TIMESTAMP=$(date +%Y%m%d_%H%M)
BACKUP_FILE="${BACKUP_DIR}/auto_backup_${TIMESTAMP}.gz"
echo "[$(date)] Starting Scheduled Backup..."
# We use the Docker CLI inside this container to talk to the MariaDB container
# The password is taken from the environment variable passed to this service
docker exec ${CONTAINER_MARIADB} mariabackup --user=root --password="${AE_DB_PASSWORD}" \
--backup --stream=xbstream --open-files-limit=65535 | gzip > "${BACKUP_FILE}"
echo "[$(date)] Backup Complete: ${BACKUP_FILE}"
# Optional: Clean up backups older than 7 days
find "${BACKUP_DIR}" -name "auto_backup_*.gz" -mtime +7 -delete

View File

@@ -0,0 +1,25 @@
#!/bin/bash
set -e
# Configuration
BACKUP_FILE="${BACKUP_FILE:-/backups/import.gz}"
RESTORE_DIR="/restore"
echo ">>> Phase 0: Wiping restore directory..."
rm -rf "${RESTORE_DIR:?}"/*
echo ">>> Phase 1: Extracting ${BACKUP_FILE} to ${RESTORE_DIR}..."
gunzip -c "${BACKUP_FILE}" | mbstream -x -C "${RESTORE_DIR}"
echo ">>> Phase 2: Fixing checkpoint metadata names..."
cd "${RESTORE_DIR}"
ln -sf mariadb_backup_checkpoints xtrabackup_checkpoints || true
ln -sf mariadb_backup_info xtrabackup_info || true
echo ">>> Phase 3: Decompressing data..."
mariabackup --decompress --target-dir="${RESTORE_DIR}" --open-files-limit=65535
echo ">>> Phase 4: Preparing backup (Applying logs)..."
mariabackup --prepare --target-dir="${RESTORE_DIR}" --open-files-limit=65535
echo ">>> Restore preparation complete!"