Last active
October 7, 2015 03:37
-
-
Save ceekz/3098850 to your computer and use it in GitHub Desktop.
Backup shell script for MySQL
This file contains hidden or 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 | |
keepday=14 | |
dir=/home/dbbackup | |
file=dump.sql | |
now_date=`date +%Y%m%d` | |
old_date=`date "-d$keepday days ago" +%Y%m%d` | |
cd $dir | |
mysqldump -u USER -h HOST --password='PASS' --default-character-set=binary --hex-blob DB > $file | |
zip -q $now_date.zip $file | |
rm -f $old_date.zip $file |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment