Skip to content

chA0s-Chris/mongo-backup

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

mongodump as an ultra-small Docker image.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published