Skip to content

Twenga/mongodb-backup

Repository files navigation

MongoDB Backup -- version 0.3.1

Shell script to backup MongoDB databases. Use mongodump command to make a hot backup of your environment.

Initially, it was designed to backup all databases on replicatSet and sharded environment. I hope to add, as soon as possible, new features in order to make these tools versatile

Functionnality

  • Stop Balancer (to prevent chunks migration during backup)
  • Multithreading dump
  • Compression
    • perform gzip compression
    • choose compression level (fast, normal, best)
  • Logging
    • Logging events to log file
    • Display events to stdout
  • Email reporting
  • Backup retention

Requirements

  • MongoDB client 2.2 or above
  • Tested operating systems: Debian/Ubuntu Linux

Setup

Clone the repository and run the install.sh script

$ git clone https://github.com/Twenga/mongodb-backup.git
$ cd mongodb-backup
$ ./install.sh

If /etc/mongodb-backup.conf already exists on your system, please check changes on /etc/mongodb-backup.conf.dist and adapt them according to your needs.

Default paramaters

Look the options in /etc/mongodb-backup.conf file. Set variables as you need especially the shard options. See comments.

Usage

Usage: mongodb-backup [options] ...

Options are...
   -h 	 Display this help message
   -j 	 Enable dump jounalisation
   -e 	 Display events to STDOUT
   -m <mail_address> 	 Set email reporting address
   -c <compress_level>	 Override compression level: normal, fast or best (default: normal)
   -u <username>
   -p <password>

Run mongodb-backup without options to do a backup with default parameters (see /etc/mongodb-backup.conf). If you don't set shard parameters it will backup config server only.

Running process description

  • Check if mongodb-backup is already running
  • Get parameters to prepare backup
  • Stop balancer
  • Dump config database
  • Dump databases -> one per shard. Pickup a slave if the shard host you specified is master
  • Start balancer
  • Compress dumped directories
  • Check backup retention
  • Send a backup report by mail (if it set)

Copyrights & licensing

Licensed under the Apache License 2.0. See LICENSE file for details.

ChangeLog

See CHANGELOG file for details.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published