Files
OSIT-AE-Docker-Env/export_db.sh

36 lines
1.1 KiB
Bash
Executable File

#!/bin/bash
# Aether Conference Export Script
# Manually triggers a hot backup for off-site use.
set -e
PROJECT_ROOT="/home/scott/OSIT_dev/aether_container_env"
EXPORT_DIR="${PROJECT_ROOT}/backups/conference_export"
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
EXPORT_FILE="conference_backup_${TIMESTAMP}.gz"
mkdir -p "$EXPORT_DIR"
echo "--- Starting Conference Database Export ---"
# Trigger the internal backup script inside the ops container
# This will create an 'auto_backup_...' file in the backups folder
docker exec ae_ops_dev bash /scripts/backup_internal.sh
# Find the most recent backup file created in the backups folder
LATEST_BACKUP=$(ls -t "${PROJECT_ROOT}/backups"/auto_backup_*.gz | head -n 1)
if [ -n "$LATEST_BACKUP" ]; then
echo ">>> Moving latest backup to export directory: ${EXPORT_FILE}"
mv "$LATEST_BACKUP" "${EXPORT_DIR}/${EXPORT_FILE}"
# Ensure final ownership is correct
chown 1000:1000 "${EXPORT_DIR}/${EXPORT_FILE}"
echo "--- Export Complete! ---"
echo "File location: ${EXPORT_DIR}/${EXPORT_FILE}"
else
echo "ERROR: Failed to find the generated backup file."
exit 1
fi