Created
June 10, 2014 18:21
-
-
Save baniol/7157822065e8cfd00303 to your computer and use it in GitHub Desktop.
mongodb dump & dropbox upload, backup
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
#!/usr/bin/env bash | |
#Get current date | |
NOW="$(date +'%d-%m-%Y_%H-%M')" | |
# Settings: | |
# Path to a temporary directory | |
DIR=/root/mongodb_dump/ | |
# Path to a target dropbox directory | |
# Remove after article - create first a target file in dropboxs | |
TARGET_DIR=/mongodb_backups | |
# Path do dropbox_uploader.sh file | |
UPLOADER_SCRIPT=/root/downloads/dropbox_uploader.sh | |
# Name of the database | |
DB_NAME=clippings | |
function mongodb_dump | |
{ | |
# Name of the compressed file | |
FILE="${DIR}${DB_NAME}_${NOW}.tar.gz" | |
echo $FILE | |
# Dump the database | |
mongodump -d $DB_NAME -o $DIR | |
# Compress~ | |
tar -zcvf $FILE $DIR$DB_NAME | |
# Remove the temporary database dump directory | |
rm -fr $DB_NAME | |
# Upload the file | |
$UPLOADER_SCRIPT upload $FILE $TARGET_DIR | |
# Remove the file | |
rm $FILE | |
} | |
mongodb_dump |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment