Sign inSign up

chaos/mongo-backup

By chaos

•Updated over 1 year ago

mongodump as an ultra-small Docker image.

Image
Databases & storage
0

395

chaos/mongo-backup repository overview

⁠mongo-backup

An ultra-small Docker image containing MongoDB's mongodump tool. It enables seamless creation of MongoDB backups without the need to install MongoDB or its dependencies on your system.

GitHub License Docker Image Version (tag) Docker Image Size Docker Pulls GitHub last commit GitHub Actions Workflow Status

⁠Table of Contents

⁠Features

  • Ultra-small: The image is about 20 MB in size and contains only mongodump and its dependencies.
  • No installation required: You can use mongodump without installing MongoDB or its dependencies on your system.
  • Easy to use: The image can be used as a drop-in replacement for mongodump in your backup scripts.

⁠Getting Started

⁠Prerequisites
  • Docker installed on your machine. That's it.
⁠Usage

To create a backup of your MongoDB database, run the following command:

docker run --rm -v /my/backup/folder:/backup chaos/mongo-backup:latest \
    --uri mongodb://localhost:27017 \
    --db MyDatabase \
    --gzip \
    --archive=/backup/mybackup.gz

Explanation:

  • --rm: Automatically remove the container when it exits.
  • -v /my/backup/folder:/backup: Mounts the local folder /my/backup/folder/ to the container's /backup directory.
  • chaos/mongo-backup:latest: Use the latest version of the chaos/mongo-backup image.
  • --uri mongodb://localhost:27017: The MongoDB connection string. You can also use mongodb://username:password@localhost:27017.
  • --db MyDatabase: The name of the database you want to dump.
  • --gzip: Compress the output using gzip.
  • --archive=/backup/mybackup.gz: Store the backup in a single file named mybackup.gz in the container's /backup directory.

You can also specify the --out option instead of --archive to create a directory containing all collections as separate dumps.

See the official MongoDB documentation⁠ for more options.

⁠Security Considerations

When using this image on the command line or in your backup scripts, especially in multi-user environments, be cautious about exposing sensitive information such as the passwords.

The recommended approach is to provide a YAML configuration for mongodump containing the connection string:

uri: mongodb://username:password@localhost:27017

Then, run the following command:

docker run --rm -v /my/backup/folder:/backup \
    -v /path/to/config.yaml:/config.yaml \
    chaos/mongo-backup:latest \
    --db MyDatabase \
    --gzip \
    --archive=/backup/mybackup.gz

⁠License

MIT License - see LICENSE⁠ for more information.

Tag summary

Content type

Image

Digest

sha256:d3c0aa627…

Size

20.4 MB

Last updated

over 1 year ago

docker pull chaos/mongo-backup