Skip to content

Instantly share code, notes, and snippets.

@ceekz
Last active Oct 7, 2015
Embed
What would you like to do?
Backup shell script for MySQL
#!/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