Skip to content

Instantly share code, notes, and snippets.

@msaiducar
Forked from sheharyarn/mongo_backup.sh
Created April 25, 2018 13:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msaiducar/a75235db0d0267eba902a8988f2f9289 to your computer and use it in GitHub Desktop.
Save msaiducar/a75235db0d0267eba902a8988f2f9289 to your computer and use it in GitHub Desktop.
Mongodump Shell Script for Cronjob
#!/bin/bash
MONGO_DATABASE="dbname"
APP_NAME="appname"
MONGO_HOST="127.0.0.1"
MONGO_PORT="27017"
TIMESTAMP=`date +%F-%H%M`
MONGODUMP_PATH="/usr/bin/mongodump"
BACKUP_NAME="$APP_NAME-$TIMESTAMP.gz"
BACKUP_PATH="/home/path/"
BACKUPS_DIR="$BACKUP_PATH/$BACKUP_NAME"
$MONGODUMP_PATH --host $MONGO_HOST --port $MONGO_PORT -d $MONGO_DATABASE --archive=$BACKUPS_DIR --gzip --quiet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment