Terraform: - Hetzner CX22 server with Docker, firewall (80/443/22) - SSH key and output for server IP Docker Compose: - Caddy reverse proxy (auto HTTPS) - Journal and Planner app containers - BRouter routing engine container - PostgreSQL + PostGIS - Garage S3 storage BRouter: - Dockerfile based on eclipse-temurin:11-jre - Segment download script for Germany (4 tiles, ~750MB) CD Pipeline: - Build & push Docker images to ghcr.io on main push - Deploy step commented out (enable when server provisioned) Scripts: - PostgreSQL daily backup with 14-day retention - Dockerfiles for both apps (multi-stage builds) Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
26 lines
900 B
Bash
Executable file
26 lines
900 B
Bash
Executable file
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
# Daily PostgreSQL backup
|
|
# Run via cron: 0 3 * * * /opt/trails-cool/scripts/backup-postgres.sh
|
|
|
|
BACKUP_DIR="${BACKUP_DIR:-/backups}"
|
|
RETENTION_DAYS="${RETENTION_DAYS:-14}"
|
|
TIMESTAMP=$(date +%Y%m%d_%H%M%S)
|
|
BACKUP_FILE="${BACKUP_DIR}/trails_${TIMESTAMP}.sql.gz"
|
|
|
|
mkdir -p "$BACKUP_DIR"
|
|
|
|
echo "[$(date)] Starting PostgreSQL backup..."
|
|
|
|
docker compose -f /opt/trails-cool/docker-compose.yml exec -T postgres \
|
|
pg_dump -U trails trails | gzip > "$BACKUP_FILE"
|
|
|
|
echo "[$(date)] Backup saved to ${BACKUP_FILE} ($(du -h "$BACKUP_FILE" | cut -f1))"
|
|
|
|
# Remove backups older than retention period
|
|
echo "[$(date)] Removing backups older than ${RETENTION_DAYS} days..."
|
|
find "$BACKUP_DIR" -name "trails_*.sql.gz" -mtime "+${RETENTION_DAYS}" -delete
|
|
|
|
echo "[$(date)] Backup complete. Current backups:"
|
|
ls -lh "$BACKUP_DIR"/trails_*.sql.gz 2>/dev/null || echo " No backups found"
|