
### MongoDB
MongoDB + Backups & Retention
[](https://git.zakscode.com/ztimson/mongodb/tags)
[](https://git.zakscode.com/ztimson/mongodb/pulls)
[](https://git.zakscode.com/ztimson/mongodb/issues)
---
---
## Table of Contents
- [MongoDB](#top)
- [About](#about)
- [Environment Variables](#environment-variables)
- [Built With](#built-with)
- [Setup](#setup)
- [Production](#production)
## About
Custom MongoDB Docker image extending `mongo:latest` with automated backup functionality.
Installs cron to run scheduled mongodump operations with compression and retention management, while preserving all native MongoDB server functionality.
Backups can be manually triggered with: `docker --exec -t mongodb backup`
To restore a backup, uncompress it and use the official `mongorestore`
### Environment Variables
| Variable | Description | Default | Example |
|-------------------------|----------------------------|---------------|---------------|
| `MONGO_INITDB_DATABASE` | Database name to backup | - | `myapp` |
| `BACKUP_CRON` | Cron schedule expression | - | `0 */6 * * *` |
| `BACKUP_DIR` | Directory to store backups | /data/backups | `/backups` |
| `BACKUP_RETENTION` | Number of backups to keep | - | `7` |
### Built With
[](https://docker.com/)
[](https://www.mongodb.com/)
## Setup