Automation: Final robust DB restore fixes and updated gitignore rules.
This commit is contained in:
29
check_and_import.sh
Executable file
29
check_and_import.sh
Executable file
@@ -0,0 +1,29 @@
|
||||
#!/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
|
||||
Reference in New Issue
Block a user