Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@droot
Created May 2, 2010 16:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save droot/387240 to your computer and use it in GitHub Desktop.
Save droot/387240 to your computer and use it in GitHub Desktop.
#!/bin/bash
RESTORE_UTILITY='/opt/mongodb/bin/mongorestore'
DB_NAME='my_db'
log() {
echo $1
}
do_restore(){
local fname=$1
tar -jxf $1 && \
${RESTORE_UTILITY} -d ${DB_NAME} ${fname//.bz2}/${DB_NAME}
}
get_file_from_s3(){
python aws_s3.py get $1
}
do_cleanup(){
rm -rf db_backup_2010*
log 'cleaning up....'
}
if [ $# -lt 1 ]
then
echo "Usage: $0 <backup_filename>"
exit 1
fi
filename=$1
get_file_from_s3 ${filename} && do_restore ${filename} && do_cleanup
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment