In this blog, I will present the new features introduced with the latest release (2.7.0) of the MongoDB DMK.
The DMK is a set of standardized tools that aims at easing the work of DBAs. It embeds the best practices of dbi in common scripts across all the database servers of an organization.
dbi services provides the DMK (Database Management Kit) to its customers for multiple technologies: Oracle, Postgres, MongoDB, etc. This toolkit is provided free of charge to all clients who work with dbi services on a consulting project.
New features of the MongoDB DMK in 2.7.0
Point-in-time recovery
PITR is the biggest addition of the release. It restores a whole instance, a database or a collection to a chosen moment, on a replica set.
dmk_oplog_backup.py, run frequently, archives the oplog in incremental slices between two full backups.dmk_restore.py --pitr <timestamp>restores a backup and replays the archived oplog up to the target. Specify a custom starting full save with-s, or leave it out. DMK can also select the newest full-instance backup that reaches the target. It asks the user for confirmation (--yesaccepts it).--out-of-placerecovers a database or a collection through a scratchmongod.dmk_pitr_status.pyshows the windows that can be recovered right now.
To restore a full instance to a specific point in time, just run the following command. Here, 150 orders were written, dmk_oplog_backup.py archived the oplog, and a deleteMany then emptied the collection. The target is just before the delete, and --yes accepts the backup that DMK selects:
Questions about your own setup? A dbi services consultant can look at your case.
Talk to an expert (opens in a new tab)$ dmk_restore.py -i mdbrs01 --pitr '2026-11-15T15:24:46' --yes
2026-11-15 15:24:53 | INFO | PITR target '2026-11-15T15:24:46' is 2026-11-15T15:24:46+00:00 = 2026-11-15T15:24:46+00:00 (1795101886:0) (exclusive).
2026-11-15 15:24:53 | INFO | No source given: selected the newest backup that reaches the target 2026-11-15T15:24:46+00:00 = 2026-11-15T15:24:46+00:00 (1795101886:0): '/u90/mongodb/backup/mdbrs01/backup_mdbrs01_20261115_152434'. Its dump ended at 2026-11-15T15:24:33+00:00 = 2026-11-15T15:24:33+00:00 (1795101873:101), the archived oplog covers up to 2026-11-15T15:24:51+00:00 = 2026-11-15T15:24:51+00:00 (1795101891:1).
2026-11-15 15:24:53 | INFO | --yes given: restoring from this backup without asking.
2026-11-15 15:24:53 | INFO | Whole-instance PITR to 2026-11-15T15:24:46+00:00 = 2026-11-15T15:24:46+00:00 (1795101886:0), beyond the oplog the base backup captured: replaying the archived oplog slices in a scratch instance (the target instance is not replayed into).
2026-11-15 15:24:54 | INFO | Restoring the base backup '/u90/mongodb/backup/mdbrs01/backup_mdbrs01_20261115_152434' into the scratch instance (replaying its own captured oplog) ...
2026-11-15 15:24:54 | INFO | Replaying archived oplog slice 1/2 ('oplog_slice_20261115_152439_899500.archive.gz') ...
2026-11-15 15:24:54 | INFO | Replaying archived oplog slice 2/2 ('oplog_slice_20261115_152450_825511.archive.gz') ...
2026-11-15 15:24:54 | INFO | Scratch instance is now at 2026-11-15T15:24:46+00:00 = 2026-11-15T15:24:46+00:00 (1795101886:0).
2026-11-15 15:24:55 | INFO | Loading the recovered instance into 'mdbrs01' ...
[...]
2026-11-15 15:24:56 | INFO | Restore summary: 150 document(s) restored, 0 failed.
2026-11-15 15:24:56 | INFO | Restore completed successfully.
2026-11-15 15:24:56 | INFO | Whole-instance PITR completed successfully.
The orders are back: shop.orders has 150 documents again. If no backup can be found, or if there is no archived slice to reach the target, the script fails without attempting the restore.
Upgrade and downgrade of MongoDB
dmk_upgrade.py and dmk_downgrade.py patch or upgrade an instance, a replica set or a sharded cluster to another MongoDB version. They stop each member, point it to the new home, start it and check the version. The previous home is put back if the new binaries do not start. --dry-run shows the plan and changes nothing. The feature compatibility version changes only with --update-fcv. dmk_upgrade_analyzer.py checks beforehand what the new version changes for the data and the configuration. --copy-home copies the home to the other servers of a deployment. A change that is interrupted, or a mongod that does not start, leaves the member on its previous home.
--status shows every member with its role, running version, home and feature compatibility version. It also shows what is still pending, without changing anything. --host-map gives the address of a host whose registered name does not resolve from where the command runs. A mongos registers its host name in config.mongos, and DMK reaches the members of the other hosts with ssh under the names registered in the deployment. If vmdmk is not known to the DNS or to /etc/hosts of the host where you run the command, ssh fails with Could not resolve hostname, and DMK tells you which name to map:
dmk_upgrade.py -i mdbxms1 --sharded-cluster --status --host-map vmdmk=10.0.0.10
The option is repeatable and applies to one command. To keep the mapping, put one name address line per host in $MONGO_BASE/etc/dmk_hosts.map (the option wins over the file). Only the host is mapped, the ports come from the deployment.
Dry run and status of a sharded cluster
The examples below run on a sharded cluster of 13 members, all on 8.0.28. It has three config servers (mdbcfg01 to mdbcfg03), three shards of three members each (mdbrs11 to mdbrs33) and one router (mdbmgs1). The command takes one instance of the local server, here the router. The dry run starts with the analysis, then prints the plan and the steps for every member:
$ dmk_upgrade.py -i mdbmgs1 --sharded-cluster --target-version 9.0.8 --dry-run
2026-11-15 15:26:08 | INFO | Instance 'mdbmgs1': current home '/u01/app/mongodb/product/8.0.28', target home '/u01/app/mongodb/product/9.0.8' (9.0.8, Community).
2026-11-15 15:26:11 | INFO | Running version: 8.0.28, FCV: n/a, role: MONGOS.
2026-11-15 15:26:19 | INFO | Topology: sharded, 13 member(s).
2026-11-15 15:26:19 | INFO | mdb-db1:27017 (config csrs, PRIMARY, 8.0.28)
2026-11-15 15:26:19 | INFO | mdb-db2:27017 (config csrs, SECONDARY, 8.0.28)
2026-11-15 15:26:19 | INFO | mdb-db3:27017 (config csrs, SECONDARY, 8.0.28)
2026-11-15 15:26:19 | INFO | mdb-db1:27018 (shard rs1, PRIMARY, 8.0.28)
2026-11-15 15:26:19 | INFO | mdb-db2:27018 (shard rs1, SECONDARY, 8.0.28)
2026-11-15 15:26:19 | INFO | mdb-db3:27018 (shard rs1, SECONDARY, 8.0.28)
2026-11-15 15:26:19 | INFO | mdb-db1:27019 (shard rs2, PRIMARY, 8.0.28)
2026-11-15 15:26:19 | INFO | mdb-db2:27019 (shard rs2, SECONDARY, 8.0.28)
2026-11-15 15:26:19 | INFO | mdb-db3:27019 (shard rs2, SECONDARY, 8.0.28)
2026-11-15 15:26:19 | INFO | mdb-db1:27020 (shard rs3, PRIMARY, 8.0.28)
2026-11-15 15:26:19 | INFO | mdb-db2:27020 (shard rs3, SECONDARY, 8.0.28)
2026-11-15 15:26:19 | INFO | mdb-db3:27020 (shard rs3, SECONDARY, 8.0.28)
2026-11-15 15:26:19 | INFO | mdb-mgs1:27017 (mongos mongos, MONGOS, 8.0.28)
2026-11-15 15:26:22 | INFO | Analysis of the upgrade from 8.0.28 to 9.0.8: 0 error(s), 0 warning(s), 4 information(s).
[...]
2026-11-15 15:26:22 | INFO | Plan:
2026-11-15 15:26:22 | INFO | 1. mdb-db2:27017 (config csrs, SECONDARY, 8.0.28)
2026-11-15 15:26:22 | INFO | 2. mdb-db3:27017 (config csrs, SECONDARY, 8.0.28)
2026-11-15 15:26:22 | INFO | 3. mdb-db1:27017 (config csrs, PRIMARY, 8.0.28)
2026-11-15 15:26:22 | INFO | 4. mdb-db2:27018 (shard rs1, SECONDARY, 8.0.28)
2026-11-15 15:26:22 | INFO | 5. mdb-db3:27018 (shard rs1, SECONDARY, 8.0.28)
2026-11-15 15:26:22 | INFO | 6. mdb-db1:27018 (shard rs1, PRIMARY, 8.0.28)
2026-11-15 15:26:22 | INFO | 7. mdb-db2:27019 (shard rs2, SECONDARY, 8.0.28)
2026-11-15 15:26:22 | INFO | 8. mdb-db3:27019 (shard rs2, SECONDARY, 8.0.28)
2026-11-15 15:26:22 | INFO | 9. mdb-db1:27019 (shard rs2, PRIMARY, 8.0.28)
2026-11-15 15:26:22 | INFO | 10. mdb-db2:27020 (shard rs3, SECONDARY, 8.0.28)
2026-11-15 15:26:22 | INFO | 11. mdb-db3:27020 (shard rs3, SECONDARY, 8.0.28)
2026-11-15 15:26:22 | INFO | 12. mdb-db1:27020 (shard rs3, PRIMARY, 8.0.28)
2026-11-15 15:26:22 | INFO | 13. mdb-mgs1:27017 (mongos mongos, MONGOS, 8.0.28)
2026-11-15 15:26:22 | INFO | FCV: raise to 9.0 afterwards (requires --update-fcv or --force-fcv-update)
2026-11-15 15:26:22 | INFO | [DRY-RUN] stop the balancer
2026-11-15 15:26:22 | INFO | --- mdb-db2:27017 (config csrs, SECONDARY, 8.0.28) ---
| 2026-11-15 15:26:24 | INFO | [DRY-RUN] 1. stop 'mdbcfg02'
| 2026-11-15 15:26:24 | INFO | [DRY-RUN] 2. point 'mdbcfg02' to '/u01/app/mongodb/product/9.0.8' (mongodb.lst, systemd unit)
| 2026-11-15 15:26:24 | INFO | [DRY-RUN] 3. start 'mdbcfg02' and check it runs 9.0.8
| 2026-11-15 15:26:24 | INFO | [DRY-RUN] 4. wait for the member to be SECONDARY and caught up
[...]
2026-11-15 15:26:27 | INFO | --- mdb-db1:27017 (config csrs, PRIMARY, 8.0.28) ---
| 2026-11-15 15:26:29 | INFO | [DRY-RUN] 1. step down the primary and wait for another member to take over
| 2026-11-15 15:26:29 | INFO | [DRY-RUN] 2. stop 'mdbcfg01'
[...]
2026-11-15 15:26:53 | INFO | The FCV was not changed. To change it, run on the mongos: db.adminCommand({"setFeatureCompatibilityVersion": "9.0", "confirm": true})
2026-11-15 15:26:53 | INFO | [DRY-RUN] start the balancer
The order is always the same: config servers, then each shard, then the routers. Inside a replica set, the secondaries come first and the primary last. The lines prefixed with | are the steps of one member. The analysis found no error and no warning, and the dry run changes nothing. Running the same command without --dry-run starts the upgrade. While it runs, --status can be run from another session. It shows where every member stands against the target. Here, the config servers and the first shard are on 9.0.8, the balancer is stopped, and one member of rs2 is being restarted, so DMK cannot read it:
$ dmk_upgrade.py -i mdbmgs1 --sharded-cluster --status --target-version 9.0.8
Sharded cluster, 13 member(s), FCV 8.0, balancer off
MEMBER KIND GROUP ROLE INSTANCE RUNNING HOME FCV NOTE
mdb-db1:27017 config csrs PRIMARY mdbcfg01 9.0.8 9.0.8 8.0
mdb-db2:27017 config csrs SECONDARY mdbcfg02 9.0.8 9.0.8 8.0
mdb-db3:27017 config csrs SECONDARY mdbcfg03 9.0.8 9.0.8 8.0
mdb-db1:27018 shard rs1 SECONDARY mdbrs11 9.0.8 9.0.8 8.0
mdb-db2:27018 shard rs1 PRIMARY mdbrs12 9.0.8 9.0.8 8.0
mdb-db3:27018 shard rs1 SECONDARY mdbrs13 9.0.8 9.0.8 8.0
mdb-db1:27019 shard rs2 PRIMARY mdbrs21 8.0.28 8.0.28 8.0 not on target
mdb-db2:27019 shard rs2 SECONDARY 8.0.28 unreadable: Command execution /u01/app/mongodb/product/8.0.28/bin/mongos, not on target
mdb-db3:27019 shard rs2 SECONDARY mdbrs23 8.0.28 8.0.28 8.0 not on target
mdb-db1:27020 shard rs3 PRIMARY mdbrs31 8.0.28 8.0.28 8.0 not on target
mdb-db2:27020 shard rs3 SECONDARY mdbrs32 8.0.28 8.0.28 8.0 not on target
mdb-db3:27020 shard rs3 SECONDARY mdbrs33 8.0.28 8.0.28 8.0 not on target
mdb-mgs1:27017 mongos mongos MONGOS mdbmgs1 8.0.28 8.0.28 not on target
Target 9.0.8: 6 of 13 member(s) run it, FCV 8.0 -> 9.0 still to change.
When the upgrade ends, DMK starts the balancer again and leaves the feature compatibility version on 8.0 (because --update-fcv was not given).
Backup and restore
- Sharded clusters.
dmk_backup.pyanddmk_restore.pyaccept amongos, with the balancer stopped and the shard keys restored. - Single database or collection. Both scripts accept
-d(--database), which limits the operation to one database. They also accept-c(--collection), which limits it to one collection and requires-d.dmk_backup.pywas renamed fromdmk_dbbackup.py, and the old name is kept as an alias. - Retention.
dmk_backup_purge.pydeletes the backups older thanBACKUP_RETENTION_DAYS(default14) and outside theBACKUP_RETENTION_COUNT(default5) most recent.dmk_backup.pyruns it after every successful backup unless--no-purgeis passed. - Safer backups. A backup is written under a temporary name and renamed at the end, so a killed backup never looks valid. A lock prevents two operations on one instance from overlapping, and credentials are masked in the logs.
Other changes
dmk_create.pyanddmk_ctl.pyreplacedmk_dbcreate.pyanddmk_db_ctl.py, which stay as aliases. The aliasesmgstart,mgstopandmgrestartcalldmk_ctl.py, and--startup-reportprints the warnings found at the start of the instance.- MongoDB 9.0 is supported, Community and Enterprise, on RHEL 8 and 9 and on Ubuntu 22.04.
- The DMK administrator user can authenticate with an X.509 client certificate instead of a password.
dmk_create.pyrefuses invalid instance names, ports and templates before it creates anything.dmk_status.pyreports the live version and edition withbuildInfo. It exits non-zero when an instance cannot be assessed.- Housekeeping
TRUNCno longer deletes the newest lines of a file that is not valid UTF-8.
Upgrading from an earlier version of DMK
If you are upgrading from DMK 2.6.0, replace the DMK folder with the new one:
cd /u01/app/mongodb/local
mv dmk .dmk_old
unzip /path/to/dmk_mongodb-2.7.0.zip
dmk
Crontab entries or scripts that call dmk_dbbackup.py directly keep working: the old name is kept as an alias for dmk_backup.py. Anyone relying on point-in-time recovery should set up dmk_oplog_backup.py in cron before needing it. PITR beyond the oplog window of a single backup depends on it having already been archiving.
If you are upgrading from DMK 2.5.0 or earlier, read the release notes of DMK 2.6.0 first.