Last active
August 29, 2015 14:23
-
-
Save justsml/05d3c1e1bf89200e4c08 to your computer and use it in GitHub Desktop.
Daily MongoDB Backup Script, Requires 7z for compression + encryption
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
BACKUP_PATH=/data/backups | |
# IMPORTANT: SET BACKUP PASSWORD, $USER IS A PLACEHOLDER | |
PASSWORD=$(USER) | |
# Add database name, or set to $1 to use command line parameters | |
DATABASE_NAME=$1 | |
BACKUP_TAG="mongodb-"$(DATABASE_NAME)"-"$(date +%F) | |
mongodump -d $(DATABASE_NAME) -o $(BACKUP_PATH)/$(BACKUP_TAG) | |
7z a -r -mx=1 -p$(PASSWORD) $(BACKUP_PATH)/$(BACKUP_TAG).7z $(BACKUP_PATH)/$(BACKUP_TAG)/$(COLLECTION)/*.*son |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment