Skip to content

Instantly share code, notes, and snippets.

@luckyyang
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luckyyang/abc1657da03b091a17a9 to your computer and use it in GitHub Desktop.
Save luckyyang/abc1657da03b091a17a9 to your computer and use it in GitHub Desktop.
mongodb数据备份
#!/bin/bash
BACKUPDIR=/home/vagrant/database_backup
DATE=`date +%Y%m%d%H%M`
mongodump -d "maodou_io_development" -o $BACKUPDIR/$DATE
tar -czf $BACKUPDIR/$DATE.tar.gz $BACKUPDIR/$DATE
rm -rf $BACKUPDIR/$DATE
find $BACKUPDIR -maxdepth 1 -name "*.tar.gz" -type f -mtime +5 -exec rm -f {} \; > /dev/null 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment