24 lines
862 B
Bash
24 lines
862 B
Bash
#!/bin/bash
|
|
# Aether Internal Backup Script (Runs inside the Cron Container)
|
|
set -e
|
|
|
|
# These are paths INSIDE the cron container
|
|
BACKUP_DIR="/backups"
|
|
TIMESTAMP=$(date +%Y%m%d_%H%M)
|
|
BACKUP_FILE="${BACKUP_DIR}/auto_backup_${TIMESTAMP}.gz"
|
|
|
|
echo "[$(date)] Starting Scheduled Backup..."
|
|
|
|
# We use the Docker CLI inside this container to talk to the MariaDB container
|
|
# The password is taken from the environment variable passed to this service
|
|
docker exec ${CONTAINER_MARIADB} mariabackup --user=root --password="${AE_DB_ROOT_PASSWORD}" \
|
|
--backup --stream=xbstream --open-files-limit=65535 | gzip > "${BACKUP_FILE}"
|
|
|
|
echo "[$(date)] Backup Complete: ${BACKUP_FILE}"
|
|
|
|
# Ensure host user can manage the backup files
|
|
chown 1000:1000 "${BACKUP_FILE}"
|
|
|
|
# Optional: Clean up backups older than 7 days
|
|
find "${BACKUP_DIR}" -name "auto_backup_*.gz" -mtime +7 -delete
|