Created
March 21, 2013 17:59
-
-
Save tsileo/5215169 to your computer and use it in GitHub Desktop.
I made a simple Python script using [bakthat](http://docs.bakthat.io), a backup utility I created, and [sh](http://amoffat.github.com/sh/), an Python subprocess interface, that makes **backing up [MongoDB](http://www.mongodb.org/) to Amazon Glacier or S3** an easier task.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sh | |
import logging | |
logging.basicConfig(level=logging.INFO, format="%(asctime)s;%(name)s;%(levelname)s;%(message)s") | |
from bakthat.helper import BakHelper | |
# Arguments for mongodump/restore command, leave empty if you want to backup your local mongo | |
# if you use authentication {"u": "user", "p": "password"} | |
MONGODUMP_PARAMS = {"u": "user", | |
"p": "password", | |
"oplog": True} | |
# Leave blank to disable encryption | |
PASSWORD = "mypassword" | |
# glacier or s3 | |
DESTINATION = "glacier" | |
# BakHelper automatically create a temp directory | |
with BakHelper("mymongobak", | |
destination="glacier", | |
password=PASSWORD, | |
tags=["mongodb"]) as bh: | |
logging.info(sh.mongodump(**MONGODUMP_PARAMS)) | |
bh.backup() | |
bh.rotate() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment