# Optional scheduled backup container. Requires the core PostgreSQL service # and its shared heimdall-net to be running first. services: backup: image: postgres:17-alpine pull_policy: always restart: unless-stopped environment: POSTGRES_HOST: postgresql POSTGRES_PORT: "5432" POSTGRES_DB: ${POSTGRES_DB:-heimdall} POSTGRES_USER: ${POSTGRES_USER:-heimdall} POSTGRES_PASSWORD_FILE: /run/secrets/db_password RUSTFS_ENDPOINT: ${RUSTFS_ENDPOINT:-http://rustfs:9000} RUSTFS_ACCESS_KEY: ${RUSTFS_ACCESS_KEY:-} RUSTFS_SECRET_KEY: ${RUSTFS_SECRET_KEY:-} RUSTFS_BUCKET: ${RUSTFS_BUCKET:-heimdall} BACKUP_RETENTION_DAYS: ${BACKUP_RETENTION_DAYS:-30} BACKUP_RETENTION_WEEKS: ${BACKUP_RETENTION_WEEKS:-12} BACKUP_LOCAL_DIR: /backups TZ: ${TZ:-Europe/Paris} secrets: - db_password volumes: - ./scripts:/scripts:ro - backup_data:/backups - heimdall_data:/source/heimdall_data networks: - heimdall-net entrypoint: ["/bin/sh", "-c"] command: - | set -e export POSTGRES_PASSWORD="$$(cat /run/secrets/db_password)" apk add --no-cache aws-cli bash coreutils echo '0 2 * * * bash /scripts/backup.sh >> /var/log/backup.log 2>&1' > /tmp/crontab.txt echo '15 2 * * * bash /scripts/backup-protected-data.sh >> /var/log/backup-protected-data.log 2>&1' >> /tmp/crontab.txt echo '0 3 * * 0 bash /scripts/backup-rustfs.sh >> /var/log/backup-rustfs.log 2>&1' >> /tmp/crontab.txt crontab /tmp/crontab.txt exec crond -f -l 2 volumes: backup_data: heimdall_data: external: true name: ${HEIMDALL_DATA_VOLUME:-docker_heimdall_data} secrets: db_password: file: ./secrets/db_password networks: heimdall-net: name: heimdall-net external: true