Sign inSign up

tarator/mongodump

By tarator

•Updated over 1 year ago

Docker container with cronjob to run mongodump for MongoDB 5.0. Based on Ubuntu 20.04

Image
1

1.7K

tarator/mongodump repository overview

⁠MongoDB 5.0 Backup with docker-compose and cron

pipeline status

Read this Blogpost⁠ for a more detailed explaination on how to use the container.

⁠Build the container

docker built -t mymongodump

⁠Docker-compose example file:

version: '3.1'
services:
  mongo:
    image: mongo:5.0
    restart: always
    volumes:
      - ./mongo_data:/data/db

  mongo-backup:
    image: tarator/mongodump:latest
    restart: always
    links:
      - mongo
    depends_on:
      - mongo
    volumes:
      - ./mongo_backup:/backup:rw
    environment:
      - MONGO_HOST=mongo
      - MONGO_PORT=27017
      - BACKUP_CRON_TIME=05 18 * * *
      - KEEP_DAYS=14

This creates a Dump of the complete MongoDB everyday at 18:05 (HeadsUp: Container-Time is UTC) in the directory ./mongo_backup. The filename of the backup looks like this: mongodump_2021-11-30_21.35.55.gz

⁠Restore backup

mongorestore --host localhost:27017 --gzip --archive=mongodump_2021-11-30_21.35.55.gz

⁠Sourcecode

https://gitlab.projecttac.com/tarator/mongodump⁠

Feel free to use and improve.

Tag summary

Content type

Image

Digest

sha256:31eaedd9d…

Size

124.2 MB

Last updated

over 1 year ago

docker pull tarator/mongodump