Giter VIP home page Giter VIP logo

mongodb-backups's Introduction

MongoDB backup

Build Status

Create MongoDB snapshots to an encrypted S3 bucket. Handle snapshot restoration from backup. Can be easily monitored by Prometheus.

Docker repository

Usage

# Launch server & scheduler
./mongodb-backups --config ./config.yaml
# List backup
./mongodb-backups --config ./config.yaml --list
# Restore specific backup
./mongodb-backups --config ./config.yaml --restore [id] --args '--drop'
# Restore last backup
./mongodb-backups --config ./config.yaml --restore-last --args '--drop'
# Arbitrary dump
./mongodb-backups --config ./config.yaml --dump

Parameters:

  • --config: Config path. Default ./config.yaml
  • --list: list backups
  • --restore: Restore specific backup from snapshot
  • --restore-last: Restore last backup from snaphost
  • --args: MongoDB restore additional arguments

Config file

  • name: backup name
  • schedule: cronjob schedule. Example: 0 * * * *
  • retention: max retention. Example: 2d, 1w, 1M, 720h
  • timeout: mongodb dump timeout
  • mongodb:
    • host: MongoDB host
    • port: MongoDB port
  • bucket:
    • s3:
      • name: bucket name
      • region: bucket region

Example:

name: integration
retention: 1w
schedule: '0 0 * * *'
timeout: 15m
mongodb:
  host: localhost
  port: 27017
bucket:
  s3:
    name: bucket-name
    region: eu-west-1

Prometheus metrics

  • mongodb_backups_scheduler_backup_total: Total number of backups (status: success / error)
  • mongodb_backups_scheduler_retention_total: Total number of successful retention cleanup (status: success / error)
  • mongodb_backups_scheduler_bucket_snapshot_count: Current number of snapshots in the bucket
  • mongodb_backups_scheduler_snapshot_size: Last snapshot size in bytes
  • mongodb_backups_scheduler_snapshot_latency: Last snapshot duration in seconds
  • mongodb_backups_scheduler_last_successful_snaphot: Last successful snapshot timestamp

All metrics have the label name equals to the config name key.

Environment variables

  • MONGODB_USER: MongoDB user
  • MONGODB_PASSWORD: MongoDB password

AWS

S3 policy example:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "0",
      "Effect": "Allow",
      "Action": [
        "s3:PutObject",
        "s3:GetObject",
        "s3:ListObject",
        "s3:DeleteObject"
      ],
      "Resource": [
        "arn:aws:s3:::my-bucket-name",
        "arn:aws:s3:::my-bucket-name/*"
      ]
    }
  ]
}

Development

Run

# With Go
go run ./cmd --config config.yaml

# With Docker
docker build -t n9-backup .
docker run --rm -v /tmp/config:/tmp/config n9-backup mongodb-backup --config /tmp/config/config.yaml

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.