Skip to content

Instantly share code, notes, and snippets.

@patrickkeller
Last active December 17, 2015 03:38
Show Gist options
  • Save patrickkeller/5544616 to your computer and use it in GitHub Desktop.
Save patrickkeller/5544616 to your computer and use it in GitHub Desktop.
MongoDB Backupscript
#!/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