31 lines
1.1 KiB
Bash
31 lines
1.1 KiB
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: Metadata Check..."
|
|
cd "${RESTORE_DIR}"
|
|
if [ -f "mariadb_backup_checkpoints" ] && [ ! -f "xtrabackup_checkpoints" ]; then
|
|
echo ">>> Linking mariadb_backup_checkpoints to xtrabackup_checkpoints..."
|
|
ln -sf mariadb_backup_checkpoints xtrabackup_checkpoints
|
|
fi
|
|
if [ -f "mariadb_backup_info" ] && [ ! -f "xtrabackup_info" ]; then
|
|
echo ">>> Linking mariadb_backup_info to xtrabackup_info..."
|
|
ln -sf mariadb_backup_info xtrabackup_info
|
|
fi
|
|
|
|
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!" |