Skip to main content
This is a pre-production deployment of Warehouse. Changes made here affect the production instance of PyPI (
Help us improve Python packaging - Donate today!

A tool to backup mongodb

Project Description

Backup mongodb data by copy dbpath


$ pip install mongodb-backup


Start a mongod instance on port 27017.

Run py.test


$ mongodbbackup --help

Make sure which mongod instance you want to backup, and run mongodbbackup on that server.


  • Backup a standalone mongod instance.

    $ mongodbbackup -p <port> --primary-ok <backup_dir>

    Caution: it will block all writes.

  • Backup a replication, run the follow command on a secondary server.

    $ mongodbbackup -p <secondary_port> <backup_dir>
  • Backup a cluster, backup a config server and each shard. If you have two shards, you need to run the follow command three times.

    $ mongodbbackup --ms-url <mongos_url> -p <port> <backup_dir>

Under The Hood

This tool backup mongodb by copying dbpath, so it must run on the same machine with the mongod instance.

  1. Fsync the mongod instance to block all writes.
  2. Copy the dbpath.
  3. Unlock the mongod instance to accept writes.

If you want to backup a mongodb cluster, you should specify --ms-url option. It will stop balancer before backup, and restart balancer after backup.

Caution: This tool doesn’t make a point-in-time backup, it just copy the data directory, you can copy back the data to restore if any disaster happens.

Release History

This version
History Node


History Node


History Node


History Node


History Node


History Node


History Node


History Node


Download Files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

File Name & Hash SHA256 Hash Help Version File Type Upload Date
(3.8 kB) Copy SHA256 Hash SHA256
Source Sep 26, 2014

Supported By

Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Google Google Cloud Servers DreamHost DreamHost Log Hosting