Skip to content

Instantly share code, notes, and snippets.

@feng88724
Created August 21, 2018 07:40
Show Gist options
  • Save feng88724/280f78a9b7d869478cee90e26f08684a to your computer and use it in GitHub Desktop.
Save feng88724/280f78a9b7d869478cee90e26f08684a to your computer and use it in GitHub Desktop.
backupdir=/home/mysql_backup
time=` date +%Y_%m_%d_%H_%M_%S `
db_host=xx.xx.xx.xx|localhost
db_user=xxx
db_pass=xxx
db_name=xxx
mysqldump -h $db_host -u $db_user -p$db_pass $db_name | gzip > $backupdir/$time.sql.gz
find $backupdir -name "*.sql.gz" -type f -mtime +5 -exec rm -rf {} \; > /dev/null 2>&1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment