Created
January 13, 2013 21:32
-
-
Save jtarleton/4526308 to your computer and use it in GitHub Desktop.
mongo backup bash script
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
#!/bin/bash | |
MONGODUMP_PATH="/usr/bin/mongodump" | |
MONGO_HOST="prod.example.com" | |
TIMESTAMP=`date +%F-%H%M` | |
S3_BUCKET_NAME="bucketname" | |
S3_BUCKET_PATH="mongodb-backups" | |
# Create backup | |
$MONGODUMP_PATH --host $HOST | |
# Add timestamp to backup | |
mv dump mongodb-$HOSTNAME-$TIMESTAMP | |
tar cf mongodb-$HOSTNAME-$TIMESTAMP.tar mongodb-$HOSTNAME-$TIMESTAMP | |
# Upload to S3 | |
s3cmd put mongodb-$HOSTNAME-$TIMESTAMP.tar s3://$S3_BUCKET_NAME/$S3_BUCKET_PATH/mongodb-$HOSTNAME-$TIMESTAMP.tar |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment