{"id":50876565,"url":"https://github.com/mxschmitt/pg-backup-scheduler","last_synced_at":"2026-06-15T10:04:01.810Z","repository":{"id":364283880,"uuid":"1126376525","full_name":"mxschmitt/pg-backup-scheduler","owner":"mxschmitt","description":"Self-hosted PostgreSQL backup scheduler with Docker-based version matching. Perfect for Supabase users avoiding premium backup costs.","archived":false,"fork":false,"pushed_at":"2026-01-08T12:21:09.000Z","size":38,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-06-12T12:28:49.846Z","etag":null,"topics":["backup","cron","devops","docker","docker-compose","go","golang","pg-dump","postgresql","scheduler","self-hosted","supabase"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mxschmitt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-01-01T19:26:38.000Z","updated_at":"2026-01-10T06:26:35.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/mxschmitt/pg-backup-scheduler","commit_stats":null,"previous_names":["mxschmitt/pg-backup-scheduler"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/mxschmitt/pg-backup-scheduler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxschmitt%2Fpg-backup-scheduler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxschmitt%2Fpg-backup-scheduler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxschmitt%2Fpg-backup-scheduler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxschmitt%2Fpg-backup-scheduler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mxschmitt","download_url":"https://codeload.github.com/mxschmitt/pg-backup-scheduler/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mxschmitt%2Fpg-backup-scheduler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34357285,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-15T02:00:07.085Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backup","cron","devops","docker","docker-compose","go","golang","pg-dump","postgresql","scheduler","self-hosted","supabase"],"created_at":"2026-06-15T10:04:00.961Z","updated_at":"2026-06-15T10:04:01.800Z","avatar_url":"https://github.com/mxschmitt.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pg-backup-scheduler\n\nPostgreSQL Backup Scheduler - A minimal, self-hosted backup service for PostgreSQL databases. Perfect for Supabase users who want automated backups without paying for premium features.\n\nUses Docker containers with matching PostgreSQL versions (like Supabase CLI) to ensure compatibility. Backups run daily via cron and are stored locally with automatic retention cleanup.\n\n**Built with Go** - single binary, no dependencies beyond Docker.\n\n## Quick Start\n\n1. Clone and configure:\n\n```bash\ngit clone https://github.com/mxschmitt/pg-backup-scheduler.git\ncd pg-backup-scheduler\ncp env.example .env\n```\n\n2. Add your database URLs to `.env`:\n\n```bash\n# Format: BACKUP_\u003cPROJECT_NAME\u003e=postgresql://user:password@host:port/database\nBACKUP_RUNNINGFOMO=postgresql://postgres.abcdefgh:password@aws-1-eu-north-1.pooler.supabase.com:5432/postgres\nBACKUP_STRIDE=postgresql://postgres:password@localhost:5432/stride_db\n```\n\nThe project name (after `BACKUP_`) is lowercased and used as the backup folder name.\n\n3. Start:\n\n```bash\ndocker compose up -d\n```\n\nBackups run daily at 00:30 (Europe/Berlin, configurable via `BACKUP_CRON`).\n\n## Configuration\n\n| Variable | Default | Description |\n|----------|---------|-------------|\n| `BACKUP_*` | - | Database URLs (prefix with `BACKUP_` + project name) |\n| `RETENTION_DAYS` | `30` | Number of days to keep backups |\n| `BACKUP_CRON` | `30 0 * * *` | Cron expression for backup schedule |\n| `TZ` | `Europe/Berlin` | Timezone for scheduling |\n| `LOCAL_BACKUP_DIR` | `./backups` | Local path for backups (use `/data/backups` in Docker) |\n| `SERVICE_PORT` | `8080` | HTTP API port |\n| `LOG_LEVEL` | `INFO` | Log level (DEBUG, INFO, WARN, ERROR) |\n| `LOG_FORMAT` | `json` | Log format (json or text) |\n\n## Usage\n\n### Check Status\n\n```bash\n# Via HTTP API\ncurl http://localhost:8080/status | jq\n\n# Via CLI tool (runs inside the container)\ndocker compose exec backup-service cli status\n```\n\n### Trigger Manual Backup\n\n```bash\n# Backup all databases\ncurl -X POST http://localhost:8080/run\n\n# Backup specific project\ncurl -X POST http://localhost:8080/run/runningfomo\n\n# Or via CLI (runs inside the container)\ndocker compose exec backup-service cli backup runningfomo\n```\n\n### API Endpoints\n\n- `GET /healthz` - Health check\n- `GET /readyz` - Readiness probe\n- `GET /status` - Service status and last run info\n- `POST /run` - Trigger backup for all databases\n- `POST /run/{project}` - Trigger backup for specific project\n\n## Backup Format\n\nBackups are stored in `backups/\u003cproject_name\u003e/YYYY-MM-DD/` and contain:\n\n1. **backup-*.tar.gz** - Archive with roles, schema, and data\n2. **manifest-*.json** - Backup metadata (timestamps, status, PostgreSQL version, database size)\n\nThe archive contains three SQL files:\n- `roles.sql` - PostgreSQL roles and permissions\n- `schema.sql` - Database schema\n- `data.sql` - Data dump\n\n## Restore\n\n```bash\n# Extract backup\ncd backups/runningfomo/2026-01-07\ntar -xzf backup-*.tar.gz\n\n# Restore (in order)\npsql $TARGET_DB_URL \u003c roles.sql\npsql $TARGET_DB_URL \u003c schema.sql\npsql $TARGET_DB_URL \u003c data.sql\n```\n\n## How It Works\n\n- Auto-detects PostgreSQL version for each database\n- Uses matching Docker container (e.g., `postgres:17`) to run `pg_dump`/`pg_dumpall`\n- Creates tar.gz archive with roles, schema, and data\n- Stores backups locally with automatic retention cleanup\n- Runs on schedule via cron (default: daily at 00:30)\n\n## Requirements\n\n- Docker (socket mounted at `/var/run/docker.sock`)\n- PostgreSQL connection strings (works with Supabase connection pooler)\n- Disk space for backups (configurable retention)\n\n## Acknowledgments\n\nThis project was inspired by and borrows concepts from the [Supabase CLI](https://github.com/supabase/cli) repository, particularly the approach of using Docker containers with matching PostgreSQL versions for database operations.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmxschmitt%2Fpg-backup-scheduler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmxschmitt%2Fpg-backup-scheduler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmxschmitt%2Fpg-backup-scheduler/lists"}