Sign inSign up

tractr/mongodb-backup

By tractr

Updated over 7 years ago

https://github.com/tractr/docker-images/tree/main/backups/mongodb

Image
0

758

tractr/mongodb-backup repository overview

Using a prepost strategy to create MongoDB backups

Volumerize can execute scripts before and after the backup process.

With this prepost strategy you can create dump of your MongoDB containers and save it with Volumerize.

Environment Variables

Aside of the required environment variables by Volumerize, this prepost strategy will require a couple of extra variables. MONGO_USERNAME MONGO_PASSWORD MONGO_HOST MONGO_PORT

NameDescription
MONGO_USERNAMEUsername of the user who will perform the restore or dump.
MONGO_PASSWORDPassword of the user who will perform the restore or dump.
MONGO_HOSTMongoDB IP or domain.
MONGO_PORTMongoDB port.

Example with Docker Compose

version: "2"

services:
  mongodb:
    image: mongo
    ports:
      - 27017:27017
    environment:
      - MONGO_INITDB_ROOT_USERNAME=root
      - MONGO_INITDB_ROOT_PASSWORD=1234
    volumes:
      - mongodb:/data/db

  volumerize:
    image: tractr/mongodb-backup
    environment:
      - VOLUMERIZE_SOURCE=/source
      - VOLUMERIZE_TARGET=file:///backup
      - MONGO_USERNAME=root # Optional
      - MONGO_PASSWORD=1234 # Optional
      - MONGO_PORT=27017 # Default to 27017
      - MONGO_HOST=mongodb # Default to mongodb
    volumes:
      - volumerize-cache:/volumerize-cache
      - backup:/backup
    depends_on:
      - mongodb

volumes:
  volumerize-cache:
  mongodb:
  backup:

Then execute docker-compose exec volumerize backup to create a backup of your database and docker-compose exec volumerize restore to restore it from your backup.

Tag summary

Content type

Image

Digest

Size

203.4 MB

Last updated

over 7 years ago

docker pull tractr/mongodb-backup