SHARE
TWEET

Untitled

a guest Dec 6th, 2016 92 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/env bash
  2. # Dump Mongo Database
  3. # Author: Danny Boscan
  4. # ----------------------------------------------------------------------------------------
  5.  
  6. source ~/.zprofile
  7. export LC_ALL=en_US.UTF-8
  8. export LANG=en_US.UTF-8
  9. export LANGUAGE=en_US.UTF-8
  10. set term_charset utf-8
  11.  
  12. source `which virtualenvwrapper.sh`
  13. workon aws
  14.  
  15. ## date format ##
  16. NOW=$(date +"%F")
  17. NOWT=$(date +"%T")
  18.  
  19. ## Backup path ##
  20. BAK_PATH="/tmp"
  21.  
  22. ## Login info ##
  23. MUSER="user"
  24. MPASS="password"
  25.  
  26. ## Database info ##
  27. DB_NAME="mongo_data_base"
  28.  
  29. ## Binary path ##
  30. MONGODUMP="/usr/bin/mongodump"
  31.  
  32. ## TAR info ##
  33. TAR="/bin/tar"
  34.  
  35. ## AWS info ##
  36. AWS_ACCESS_KEY_ID=""
  37. AWS_SECRET_ACCESS_KEY=""
  38. AWS_STORAGE_BUCKET_NAME=""
  39. REGION="sa-east-1"
  40. AWS_CLI="/usr/bin/aws"
  41.  
  42. ## Code ##
  43. FILE="$BAK_PATH/$DB_NAME"
  44. TAR_FILE="$BAK_PATH/mongo-$DB_NAME-$NOW-$NOWT.tar"
  45.  
  46. $MONGODUMP --username=$MUSER --password=$MPASS -d $DB_NAME -o $FILE
  47.  
  48. $AWS_CLI s3 cp $TAR_FILE s3://$AWS_STORAGE_BUCKET_NAME/
  49.  
  50. $TAR -zcf $TAR_FILE -C $FILE .
  51.  
  52. /bin/rm -Rf $FILE
  53. /bin/rm -f $TAR_FILE
  54.  
  55. deactivate
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top