Skip to content

Instantly share code, notes, and snippets.

@zerefdev
Created May 11, 2021 15:39
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 zerefdev/0a51a4a77efa5b3417059b2309045917 to your computer and use it in GitHub Desktop.
Save zerefdev/0a51a4a77efa5b3417059b2309045917 to your computer and use it in GitHub Desktop.
MongoDB Backup Script
#!/bin/sh
BACKUP_NAME=mongo_backup_`date +"%d-%m-%Y"`.gz
DB=db_name
USER=db_user
PASS=db_password
echo "Dumping MongoDB $DB database to compressed archive"
mongodump --db $DB --username=$USER --password=$PASS --archive=$HOME/backups/$BACKUP_NAME --gzip
echo "Backup complete!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment