Sign inSign up

jakelow/mongodumper

By jakelow

•Updated almost 8 years ago

Image
0

793

jakelow/mongodumper repository overview

⁠Mongodumper

Mongodumper is a Docker microservice that makes periodic backups of your MongoDB database. It saves these backups as gzipped archive files to a Docker volume named /backups. You can then back these files up any way you wish (e.g. by copying them to S3, or snapshotting the disk they live on). Mongodumper deletes old archives so they don't fill up your host's hard drive.

⁠Configuration

The following environment variables can be used to configure Mongodumper:

Variable NameDefault ValueDescription
MONGO_HOSTmongoHostname to connect to
MONGO_PORT27017Port number to connect to
KEEP_MOST_RECENT_N14How many backups to keep
CRON_SCHEDULE0 0 * * * (daily at 00:00 UTC)How often to create a new backup

⁠Example

version: "3"

services:
  mongo:
    image: mongo

  mongodumper:
    image: jakelow/mongodumper
    volumes:
      - mongo_backups:/backups
    environment:
      CRON_SCHEDULE: "0/5 * * * *"
      KEEP_MOST_RECENT_N: "5"

volumes:
  mongo_backups:
    driver: local

If you ran docker-compose up and then waited half an hour, you'd see something like this if you ran ls inside the mongo_backups volume:

2019-01-04T20:32:00Z.archive.gz
2019-01-04T20:37:00Z.archive.gz
2019-01-04T20:42:00Z.archive.gz
2019-01-04T20:47:00Z.archive.gz
2019-01-04T20:52:00Z.archive.gz

⁠Restoring

Mongodumper generates backup files using mongodump --archive --gzip. Each of the generated files contains a complete backup of all databases in MongoDB, excluding the local database. To restore from one of these files, run mongorestore --archive --gzip. See the MongoDB mongorestore documentation⁠ for more details.

⁠Compatibility

Tested with Mongo 3.2. Newer versions (including 4.x) should also work. I'm not sure how far back compatibility goes for older versions.

No matter which version you're using, be sure to test your backup and restore workflow before you need it.

⁠License

This repository is licensed under the MIT license; see the LICENSE file for details.

⁠Credits

Thanks to Ilya Stepanov⁠ for the inspiration.

Tag summary

Content type

Image

Digest

Size

30.9 MB

Last updated

almost 8 years ago

docker pull jakelow/mongodumper