Last active
December 17, 2015 03:38
-
-
Save patrickkeller/5544616 to your computer and use it in GitHub Desktop.
MongoDB Backupscript
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_source="/var/mongobackup/db" | |
backup_dest="/var/mongobackup" | |
now=$(date +"%d_%m_%Y") | |
filename="db_prod_back_$now.tgz" | |
# make a dump of all mongodbs | |
mongodump -o "/var/mongobackup/" | |
# remove old backup | |
rm "/var/mongobackup"/*.tgz | |
# make .tgz package | |
tar cvpzf $backup_dest/$filename $backup_source | |
# change owner to "mongobackup" | |
chown mongobackup $backup_dest/$filename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment