{"id":31647563,"url":"https://github.com/servicestack/backup-postgres","last_synced_at":"2025-10-07T06:20:07.010Z","repository":{"id":315117475,"uuid":"1051957717","full_name":"ServiceStack/backup-postgres","owner":"ServiceStack","description":"Docker images to backup and restore postgres","archived":false,"fork":false,"pushed_at":"2025-09-07T05:16:41.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-09-30T09:54:56.721Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ServiceStack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2025-09-07T04:54:49.000Z","updated_at":"2025-09-07T05:16:44.000Z","dependencies_parsed_at":"2025-09-16T21:30:07.146Z","dependency_job_id":"e8e33a91-e1d6-4c1b-8243-27835995f928","html_url":"https://github.com/ServiceStack/backup-postgres","commit_stats":null,"previous_names":["servicestack/backup-postgres"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ServiceStack/backup-postgres","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ServiceStack%2Fbackup-postgres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ServiceStack%2Fbackup-postgres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ServiceStack%2Fbackup-postgres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ServiceStack%2Fbackup-postgres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ServiceStack","download_url":"https://codeload.github.com/ServiceStack/backup-postgres/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ServiceStack%2Fbackup-postgres/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278729514,"owners_count":26035670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"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":[],"created_at":"2025-10-07T06:20:04.367Z","updated_at":"2025-10-07T06:20:06.999Z","avatar_url":"https://github.com/ServiceStack.png","language":"Shell","readme":"# PostgreSQL Backup Service\n\nA containerized PostgreSQL backup service that automatically creates database backups with configurable retention policies and optional S3/R2 cloud storage sync.\n\n## Features\n\n- 🔄 **Automated Backups**: Configurable backup intervals (default: 24 hours)\n- 🗂️ **Retention Policies**: Automatic cleanup of old backups (local and cloud)\n- ☁️ **Cloud Storage**: Support for AWS S3 and Cloudflare R2\n- 🐳 **Container Ready**: Works with Docker Compose and Kamal accessories\n- 📊 **Health Checks**: Built-in health monitoring\n- 🔒 **Secure**: Uses environment variables for credentials\n\n## Quick Start\n\n### Using Docker Compose\n\n1. Create a `.env` file with your database credentials:\n\n```env\nPOSTGRES_USER=myuser\nPOSTGRES_PASSWORD=mypassword\nPOSTGRES_DB=mydatabase\n\n# Optional: S3/R2 configuration\nS3_BUCKET=my-backup-bucket\nS3_PREFIX=db-backups\nAWS_ACCESS_KEY_ID=your-access-key\nAWS_SECRET_ACCESS_KEY=your-secret-key\nAWS_DEFAULT_REGION=us-east-1\n\n# For Cloudflare R2, also set:\nAWS_ENDPOINT_URL=https://your-account-id.r2.cloudflarestorage.com\n```\n\n2. Use the provided `compose.yml`:\n\n```bash\ndocker compose up -d\n```\n\n### Using Kamal Accessory\n\nAdd to your `config/deploy.yml`:\n\n```yaml\naccessories:\n  postgres-backup:\n    image: ghcr.io/servicestack/backup-postgres:latest\n    host: your-server\n    env:\n      clear:\n        POSTGRES_HOST: postgres\n        BACKUP_INTERVAL: \"86400\"  # 24 hours\n        RETENTION_DAYS: \"7\"\n        S3_BUCKET: \"your-backup-bucket\"\n        S3_PREFIX: \"db-backups\"\n        S3_RETENTION_DAYS: \"30\"\n      secret:\n        - POSTGRES_USER\n        - POSTGRES_PASSWORD\n        - POSTGRES_DB\n        - AWS_ACCESS_KEY_ID\n        - AWS_SECRET_ACCESS_KEY\n        - AWS_DEFAULT_REGION\n        - AWS_ENDPOINT_URL  # For R2\n    volumes:\n      - \"/opt/backups:/backups\"\n    depends_on:\n      - postgres\n```\n\n## Configuration\n\n### Environment Variables\n\n| Variable | Required | Default | Description |\n|----------|----------|---------|-------------|\n| `POSTGRES_HOST` | ✅ | - | PostgreSQL server hostname |\n| `POSTGRES_USER` | ✅ | - | Database username |\n| `POSTGRES_PASSWORD` | ✅ | - | Database password |\n| `POSTGRES_DB` | ✅ | - | Database name |\n| `BACKUP_INTERVAL` | ❌ | `86400` | Backup interval in seconds |\n| `RETENTION_DAYS` | ❌ | `7` | Local backup retention in days |\n| `S3_BUCKET` | ❌ | - | S3/R2 bucket name |\n| `S3_PREFIX` | ❌ | `db-backups` | S3/R2 prefix/folder |\n| `S3_RETENTION_DAYS` | ❌ | - | Cloud backup retention in days |\n| `AWS_ACCESS_KEY_ID` | ❌ | - | AWS/R2 access key |\n| `AWS_SECRET_ACCESS_KEY` | ❌ | - | AWS/R2 secret key |\n| `AWS_DEFAULT_REGION` | ❌ | - | AWS region |\n| `AWS_ENDPOINT_URL` | ❌ | - | Custom endpoint (for R2) |\n\n### Backup Schedule\n\n- **Default**: Every 24 hours (`BACKUP_INTERVAL=86400`)\n- **Custom**: Set `BACKUP_INTERVAL` to any value in seconds\n- **Examples**:\n  - Every 6 hours: `BACKUP_INTERVAL=21600`\n  - Every 12 hours: `BACKUP_INTERVAL=43200`\n  - Every hour: `BACKUP_INTERVAL=3600`\n\n### Retention Policies\n\n- **Local**: Controlled by `RETENTION_DAYS` (default: 7 days)\n- **Cloud**: Controlled by `S3_RETENTION_DAYS` (optional)\n- Cleanup runs after each backup\n\n## Storage Options\n\n### Local Storage Only\n\nSet only the PostgreSQL connection variables. Backups will be stored locally with the configured retention policy.\n\n### AWS S3\n\n```env\nS3_BUCKET=my-backup-bucket\nAWS_ACCESS_KEY_ID=your-access-key\nAWS_SECRET_ACCESS_KEY=your-secret-key\nAWS_DEFAULT_REGION=us-east-1\n```\n\n### Cloudflare R2\n\n```env\nS3_BUCKET=my-backup-bucket\nAWS_ACCESS_KEY_ID=your-r2-access-key\nAWS_SECRET_ACCESS_KEY=your-r2-secret-key\nAWS_ENDPOINT_URL=https://your-account-id.r2.cloudflarestorage.com\n```\n\n## Development\n\n### Local Development\n\nUse the development compose file:\n\n```bash\ndocker compose -f compose.dev.yml up -d\n```\n\nThis builds the image locally instead of pulling from the registry.\n\n### Building the Image\n\n```bash\ndocker build -t backup-postgres .\n```\n\n## Monitoring\n\n### Health Checks\n\nThe container includes health checks that verify the backup service is running:\n\n```bash\ndocker ps  # Check health status\ndocker logs postgres_backup  # View logs\n```\n\n### Logs\n\nThe service provides detailed logging with timestamps:\n\n```bash\ndocker compose logs -f postgres_backup\n```\n\n## Troubleshooting\n\n### Common Issues\n\n1. **Connection Failed**: Verify PostgreSQL credentials and network connectivity\n2. **S3 Upload Failed**: Check AWS credentials and bucket permissions\n3. **Permission Denied**: Ensure backup volume has proper write permissions\n\n### Debug Mode\n\nAdd verbose logging by checking container logs:\n\n```bash\ndocker compose logs postgres_backup\n```\n\n## License\n\nMIT License - see LICENSE file for details.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fservicestack%2Fbackup-postgres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fservicestack%2Fbackup-postgres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fservicestack%2Fbackup-postgres/lists"}