Add healthchecks
All checks were successful
Docker Build and Push / build (push) Successful in 35s

This commit is contained in:
2025-07-30 15:53:51 +12:00
parent c02723a265
commit ac44356633
4 changed files with 57 additions and 15 deletions

View File

@@ -40,7 +40,7 @@ docker push your-registry/postgres-backup:latest
- `S3_PREFIX`: S3 key prefix for backups (default: postgres-backups)
- `S3_REGION`: S3 region (default: us-east-1)
- `BACKUP_RETENTION_DAYS`: Number of days to keep backups (default: 7)
- `WEBHOOK_URL`: Optional webhook URL for notifications
- `HEALTHCHECKS_URL`: Healthchecks.io ping URL for monitoring (optional)
## Running Locally
@@ -53,6 +53,7 @@ docker run --rm \
-e S3_ENDPOINT=https://nyc3.digitaloceanspaces.com \
-e S3_ACCESS_KEY_ID=your-access-key \
-e S3_SECRET_ACCESS_KEY=your-secret-key \
-e HEALTHCHECKS_URL=https://hc-ping.com/your-uuid \
your-registry/postgres-backup:latest
```
@@ -85,6 +86,31 @@ kubectl get jobs
kubectl logs -l job-name=postgres-backup-<timestamp>
```
## Monitoring with Healthchecks.io
The container has built-in support for [Healthchecks.io](https://healthchecks.io) monitoring:
### Setup:
1. Create a check on healthchecks.io
2. Copy the ping URL (e.g., `https://hc-ping.com/your-uuid-here`)
3. Add it to your Kubernetes secret as `healthchecks-url`
### Webhook Behavior:
- **Start**: Pings `/start` when backup begins
- **Success**: Pings the main URL when all backups complete successfully
- **Failure**: Pings `/fail` with error details when any backup fails
### Example healthchecks.io URL:
```
https://hc-ping.com/12345678-1234-1234-1234-123456789012
```
This will automatically track:
- Job start times
- Success/failure status
- Failure reasons in the check log
- Missing backup alerts if job doesn't run
## Backup Structure
Backups are stored in S3 with a simple flat structure: