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

30 lines
822 B
Bash
Executable File

#!/bin/bash
# Aether Automated Import Watchdog
# Checks 'backups/import/' for new database files and restores them.
set -e
PROJECT_ROOT="/home/scott/OSIT_dev/aether_container_env"
IMPORT_DIR="${PROJECT_ROOT}/backups/import"
ARCHIVE_DIR="${PROJECT_ROOT}/backups/imported"
mkdir -p "$IMPORT_DIR" "$ARCHIVE_DIR"
# Find the newest .gz file in the import directory
NEW_BACKUP=$(ls -t "$IMPORT_DIR"/*.gz 2>/dev/null | head -n 1)
if [ -n "$NEW_BACKUP" ]; then
echo "--- New Backup Detected: $(basename "$NEW_BACKUP") ---"
# Run the restore
"${PROJECT_ROOT}/restore_db.sh" "$NEW_BACKUP"
# Move to archive
echo ">>> Archiving imported file..."
mv "$NEW_BACKUP" "$ARCHIVE_DIR/"
echo "--- Automated Import Finished ---"
else
echo "No files found in $IMPORT_DIR. Nothing to do."
fi