Added replica init
All checks were successful
Build and publish / Build Container (push) Successful in 1m47s

This commit is contained in:
2026-06-12 02:24:35 -04:00
parent 34c5c3b3e1
commit f81e6cd951
3 changed files with 69 additions and 16 deletions

View File

@@ -41,25 +41,28 @@ MongoDB + Backups & Retention
## About
Custom MongoDB Docker image extending `mongo:latest` with automated backup functionality.
Custom MongoDB Docker image extending `mongo:latest` with automated backups, retention management, and replica set configuration.
Installs cron to run scheduled mongodump operations with compression and retention management, while preserving all native MongoDB server functionality.
Includes cron-based scheduled `mongodump` operations with compression, automatic stale lock recovery on unclean shutdowns, and zero-config replica set initialization — while preserving all native MongoDB functionality.
Backups can be manually triggered with: `docker --exec -t mongodb backup`
**Manually trigger a backup:**
docker exec -t mongodb backup
To restore a backup, uncompress it and use the official `mongorestore`
**Restore a backup:**
Decompress the archive and use the official `mongorestore` tool.
### Environment Variables
| Variable | Description | Default | Example |
|------------------------------|--------------------------------------------------|--------------------------|---------------|
| `BACKUP_CRON` | Cron schedule expression | | `0 */6 * * *` |
| `BACKUP_DIR` | Directory to store backups | `/data/backups` | `/backups` |
| `BACKUP_DB` | Database to backup | `$MONGO_INITDB_DATABASE` | `admin` |
| `BACKUP_RETENTION` | Number of backups to keep, defaults to unlimited | | `7` |
| `MONGO_INITDB_DATABASE` | Default database name | | `momentum` |
| `MONGO_INITDB_ROOT_USERNAME` | Root username for mongodump auth | | `root` |
| `MONGO_INITDB_ROOT_PASSWORD` | Root password for mongodump auth | | `secret` |
| Variable | Description | Default | Example |
|------------------------------|----------------------------------------------------------------------|--------------------------|-----------------------|
| `BACKUP_CRON` | Cron schedule expression | | `0 */6 * * *` |
| `BACKUP_DIR` | Directory to store backups | `/data/backups` | `/backups` |
| `BACKUP_DB` | Database to backup | `$MONGO_INITDB_DATABASE` | `admin` |
| `BACKUP_RETENTION` | Number of backups to keep, defaults to unlimited | | `7` |
| `MONGO_INITDB_DATABASE` | Default database name | | `momentum` |
| `MONGO_INITDB_ROOT_USERNAME` | Root username for mongodump auth | | `root` |
| `MONGO_INITDB_ROOT_PASSWORD` | Root password for mongodump auth | | `secret` |
| `REPLICA` | Comma-separated list of replica hostnames to init/join a replica set | | `db1:27017,db2:27017` |
### Built With