Created
May 2, 2010 16:03
-
-
Save droot/387237 to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/sh | |
MONGODB_SHELL='/opt/mongodb/bin/mongo' | |
DUMP_UTILITY='/opt/mongodb/bin/mongodump' | |
DB_NAME='my_db' | |
date_now=`date +%Y_%m_%d_%H_%M_%S` | |
dir_name='db_backup_'${date_now} | |
file_name='db_backup_'${date_now}'.bz2' | |
log() { | |
echo $1 | |
} | |
do_cleanup(){ | |
rm -rf db_backup_2010* | |
log 'cleaning up....' | |
} | |
do_backup(){ | |
log 'snapshotting the db and creating archive' && \ | |
${MONGODB_SHELL} admin fsync_lock.js && \ | |
${DUMP_UTILITY} -d ${DB_NAME} -o ${dir_name} && tar -jcf $file_name ${dir_name} | |
${MONGODB_SHELL} admin unlock.js && \ | |
log 'data backd up and created snapshot' | |
} | |
save_in_s3(){ | |
log 'saving the backup archive in amazon S3' && \ | |
python aws_s3.py set ${file_name} && \ | |
log 'data backup saved in amazon s3' | |
} | |
do_backup && save_in_s3 && do_cleanup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment