Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- MONGO_DATABASE="DB_NAME"
- APP_NAME="APP_NAME"
- MONGO_HOST="127.0.0.1"
- MONGO_PORT="27017"
- MONGO_USER="DB_USER"
- MONGO_PASS="DB_PASS"
- TIMESTAMP=`date +%F-%H%M`
- MONGODUMP_PATH="/usr/bin/mongodump"
- BACKUPS_DIR="/home/ec2-user/backups/$APP_NAME"
- BACKUP_NAME="$APP_NAME-$TIMESTAMP"
- AUTHENTICATION_DB="admin"
- $MONGODUMP_PATH -h $MONGO_HOST:$MONGO_PORT -u $MONGO_USER -p $MONGO_PASS -d $MONGO_DATABASE --authenticationDatabase=$AUTHENTICATION_DB
- mkdir -p $BACKUPS_DIR
- mv dump $BACKUP_NAME
- tar -zcvf $BACKUPS_DIR/$BACKUP_NAME.tgz $BACKUP_NAME
- rm -rf $BACKUP_NAME
- aws s3 cp $BACKUPS_DIR/$BACKUP_NAME.tgz s3://BUCKET_NAME/backups/
- rm -rf $BACKUPS_DIR/$BACKUP_NAME.tgz
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement