Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Backup MongoDB databases with Dropbox and Dokku
#!/bin/bash
echo "Backing up MongoDB databases to Dropbox ..."
dt=$(date +"%Y-%m-%d")
echo " today is $dt"
BACKUP_PATH=~/Dropbox/mongo/backup/$(date +"%Y")/$(date +"%B")
echo " creating $BACKUP_PATH .."
dbs=$(dokku mongo:list | grep mongo | cut -f1 -d' ')
for db in $dbs
do
echo " backing up $db ..."
mkdir -p $BACKUP_PATH/$db
f=$BACKUP_PATH/$db/$dt-$db.tar
rm -f $f
dokku mongo:export $db > $f
gzip -f $f
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment