Skip to content

Instantly share code, notes, and snippets.

@xeron
Created July 13, 2010 17:39
Show Gist options
  • Save xeron/474220 to your computer and use it in GitHub Desktop.
Save xeron/474220 to your computer and use it in GitHub Desktop.
#!/bin/sh
today=`date +%Y_%m_%d`
backdir=$HOME/mysql/$today
mkdir -p $backdir
for i in `echo "show databases" | mysql -uUser -pPassword | sed 1d`; do
mysqldump -uUser -pPassword $i | gzip > $backdir/$i.sql.gz;
done;
find $backdir/.. -mtime +30 -exec rm -rf {} \;
find $backdir/.. -type d -empty -exec rm -rf {} \;
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment