MongoDB
SafeGrd backs up MongoDB 7 and 8 with mongodump. This page covers what the host needs, what the archive holds, and how a restore works.
# MongoDB 7 and 8 (each run by the test suite)
safegrd backup --database-url "mongodb://backup:$DB_PASSWORD@db.internal:27017/app?authSource=admin" --retention-days 14
MongoDB surfaces capture database archives using native mongodump --archive,
streaming data directly into the snapshot stream. Because the archive uses MongoDB's standard
format, it can be restored directly with mongorestore independently of SafeGrd. Document
counts and collection checksums generated by mongodump are validated as the stream passes.
- The host needs the MongoDB Database Tools (
mongodb-database-tools), from MongoDB's apt or yum repository or its download page: Ubuntu and Debian do not ship them.SAFEGRD_MONGODUMPandSAFEGRD_MONGORESTOREname them explicitly. The connection string goes to them in a private, owner-only file, never on their command line. - Collections are read consistently per-collection, but point-in-time consistency across different collections is not guaranteed because database-scoped dumps do not capture global oplogs. Documents modified across collections during backup execution may reflect slightly different timestamps.
- Indexes and view definitions are preserved in the backup. Server-level users and roles are managed globally and are not included in single-database archives.
- Restores target an empty database (which can have any name) and verify document counts against the snapshot manifest. If a restore fails prematurely, drop the target database before attempting a rerun.