Skip to content

Instantly share code, notes, and snippets.

@yesmeck
Created October 27, 2011 05:13
Show Gist options
  • Save yesmeck/1318833 to your computer and use it in GitHub Desktop.
Save yesmeck/1318833 to your computer and use it in GitHub Desktop.
mysql backup
#!/bin/bash
max_file_count=15
file_count=$(ls mysql-* | wc -l)
if [ $file_count -gt $max_file_count ]
then
rm mysql-*
fi
current_dir=$(dirname $0)
now=$(date +%Y-%m-%d)
db_user="root"
db_password="asdf"
mysqldump --user=$db_user --password=$db_password --all-databases > $current_dir/mysql-$now.sql
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment