Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@justsml
Last active August 29, 2015 14:23
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 justsml/05d3c1e1bf89200e4c08 to your computer and use it in GitHub Desktop.
Save justsml/05d3c1e1bf89200e4c08 to your computer and use it in GitHub Desktop.
Daily MongoDB Backup Script, Requires 7z for compression + encryption
#! /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