Coder Social home page Coder Social logo

fzunino / mongo-ec2-consistent-backup Goto Github PK

View Code? Open in Web Editor NEW

This project forked from octplane/mongo-ec2-consistent-backup

1.0 2.0 0.0 78 KB

Backup your mongo DB to the cloud

Home Page: http://rubydoc.info/github/octplane/mongo-ec2-consistent-backup/master/frames

License: Other

mongo-ec2-consistent-backup's Introduction

Mongo consistent backup over RAID EBS disks on EC2 instance

Suite of tools to backup and manage snapshots of MongoDB data set to EC2 Snapshots.

Lock and Snapshot: lock_and_snapshot.rb

Usage

Snapshot a list of devices on a given instance on ec2. Requires network access in order to lock and unlock Mongo

./lock_and_snapshot.rb -a ACCESS_KEY_ID -s SECRET_ACCESS_KEY --hostname server01 --devices /dev/sdl,/dev/slm --type daily --limit 4
  • --port, -p : Mongo port to connect to (default: 27017)
  • --access-key-id, -a : Access Key Id for AWS
  • --secret-access-key, -s : Secret Access Key for AWS
  • --devices, -d : Devices to snapshot, comma separated
  • --hostname, -h : Hostname to look for. Should resolve to a local EC2 Ip
  • --type, -t : Snapshot type, to choose among snapshot,weekly,monthly,daily,yearly (default: snapshot)
  • --limit, -l : Cleanup old snapshots to keep only limit snapshots. Default values are stored in EC2VolumeSnapshoter::KIND
  • --region: Region hosting the instances
  • --help, -e: Show this message

Usage in chef environment

In order to run the command from a remote server (the Chef server or any administrative node of your grid), you need to be able to know the lists of the devices you wish to snapshot.

By using the ohai-raid plugin (https://github.com/octplane/ohai-raid), Chef clients can fill part of their Chef registry with information about the software managed RAID arrays running. This information can be fetched out for use at a later point via the knife script provided in the ohai-raid package:

knife exec scripts/show_raid_devices server01.fqdn.com /dev/md0
/dev/sdl,/dev/sdm,/dev/sdn,/dev/sdo

You can combine the two tools to automate daily backup of you MongoDB server:

./lock_and_snapshot.rb -a ACCESS_KEY_ID -s SECRET_ACCESS_KEY --hostname server01 --devices $(knife exec /path/to/scripts/show_raid_devices server01.fqdn.com /dev/md0) --type daily

Tool Description

  • Find instance id by resolving the hostname provided in the CLI and scanning the instances in EC2
  • Lock Mongo by connecting via the hostname:port provided in the parameters
  • Snapshot the disks, delete old backups
  • Unlock Mongo

MD inspection: ec2-consistent-backup.rb

Usage

This script demonstrates the way it analyses Mongo DB Data path to extract the MD device and components associated

./ec2-consistent-backup -p 27017 

Tool description

  • connect to mongo at port provided, retrieves dbpath
  • find what mount this dbpath corresponds to
  • use /proc/mdstat to find out which drive are corresponding to the dbpath mount disk

API

Internal API documentation is at: http://rubydoc.info/github/octplane/mongo-ec2-consistent-backup/master/frames

mongo-ec2-consistent-backup's People

Contributors

octplane avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.