26 lines
806 B
Bash
26 lines
806 B
Bash
#!/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!"
|