Skip to content

Instantly share code, notes, and snippets.

@muratgozel
Created April 22, 2019 13:47
Show Gist options
  • Save muratgozel/04b324bd2e7b114172b934e7b758e162 to your computer and use it in GitHub Desktop.
Save muratgozel/04b324bd2e7b114172b934e7b758e162 to your computer and use it in GitHub Desktop.
#!/bin/bash
# set env vars from .env file
set -a
. $1
set +a
# set backup filename
datetime=$(date +%Y-%m-%d-%H-%M-%S)
filename="${datetime}.gz"
filepath=${GOOGLE_DRIVE_BACKUP_PATH}/${MONGODB_NAME}/${filename}
# backup
/usr/bin/mongodump --port $MONGODB_PORT --host 127.0.0.1 --username $MONGODB_USERADMIN --password "$MONGODB_USERADMIN_PASS" --db $MONGODB_NAME --authenticationDatabase admin --archive=$filepath --gzip
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment