Skip to content

Backup mongodb database using mongo-tools and upload to google cloud storage

License

Notifications You must be signed in to change notification settings

arizalsaputro/mongo-gcs-backup-docker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mongodb-gcs-backup-docker Docker Build Status

This project aims to provide a simple way to perform a MongoDB server/db backup using mongo-tools and to upload it to Google Cloud Storage. It was greatly inspired from https://github.com/birotaio/mongodb-gcs-backup.

Usage

You can find the built image on Docker Hub. Then, set following environment variable when running the docker container:

Environment Variable Required Default Description
GCS_KEY_FILE_PATH YES Path to service account key file. You can either mount the key file to the container or rebuild another image based on this image with additional key file
GCS_BUCKET YES Name of the Google Cloud Storage bucket
CRON_EXPRESSION NO 0 0 * * * Cron expression to control backup interval
MONGODB_HOST NO localhost The host variable that will pass to mongodump command
MONGODB_PORT NO 27017 The port variable that will pass to mongodump command
MONGODB_DB NO Name of the database to perform backup. Not specifying means backup all databases
MONGODB_USER NO In case that your mongo instance requires authentication
MONGODB_PASSWORD NO In case that your mongo instance requires authentication
MONGODB_OPLOG NO Set this to true if you want to perform mongodump with --oplog flag on. Read more
BACKUP_DIR NO /backup Path to directory of the backup file.
SLACK_ALERTS No
SLACK_WEBHOOK_URL No
SLACK_CHANNEL No
SLACK_USERNAME No
SLACK_ICON No
SLACK_ICON_URL No

Use with docker-compose

version: '3.1'

services:
  db_backup:
      image: arizalsaputro/mongo-gcs-backup
      environment:
        - MONGODB_HOST=yourmongodbhost
        - MONGODB_PORT=yourmongodbport
        - MONGODB_DB=yourmongodbdatabase
        - CRON_EXPRESSION=59 23 * * *
        - GCS_KEY_FILE_PATH=/your-path-of/service-account.json
        - GCS_BUCKET=gs://yourname-of-bucket
        - SLACK_ALERTS=true
        - SLACK_WEBHOOK_URL=https://your-slack-webhook-url
        - SLACK_CHANNEL=#yourchannelorusername
      secrets:
        - service_account
secrets:
  service_account:
    file: service_account.json      

About

Backup mongodb database using mongo-tools and upload to google cloud storage

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published