Skip to content

Instantly share code, notes, and snippets.

@dkreider
Forked from sheharyarn/mongo_backup.sh
Last active June 3, 2019 12:34
Show Gist options
  • Save dkreider/b723e37c134611724ec0af536d6d6174 to your computer and use it in GitHub Desktop.
Save dkreider/b723e37c134611724ec0af536d6d6174 to your computer and use it in GitHub Desktop.
Mongodump Shell Script for Cronjob
#!/bin/bash
MONGO_DATABASE="your_db_name"
MONGO_HOST="127.0.0.1"
MONGO_PORT="27017"
TIMESTAMP=`date +%F`
MONGODUMP_PATH="/usr/bin/mongodump"
BACKUPS_DIR="/home/username/backups/$APP_NAME"
BACKUP_NAME="$TIMESTAMP"
mkdir -p $BACKUPS_DIR
$MONGODUMP_PATH -d $MONGO_DATABASE -o $BACKUPS_DIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment