Backup a cloud MongoDB database on your computer
If you're deploying your apps on Heroku, AppFog or other PaaS provider, you're probably keeping your MongoDB data on MongoLab or MongoHQ.
Here's a short shell script to do a local, compressed and timestamped backup of a MongoLab database:
#!/bin/sh
echo "\n\n\nDownloading database...\n\n\n"
mongodump -h dsXXXXXX.mongolab.com:XXXXX \
-d database_name \
-u user_name \
-p secret_password \
-o ./backup/mongolab
echo "\n\n\nArchiving temporary backup folder...\n\n\n"
zip -r ./backup/mongolab-$(date +"%Y%m%d-%H%M%S").zip ./backup/mongolab
echo "\n\n\nDeleting temporary backup folder..."
rm -R ./backup/mongolab
echo "\nDone."
Written by Ionut-Cristian Florescu
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#