Skip to content

Instantly share code, notes, and snippets.

@mrmichalis
Created January 8, 2013 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save mrmichalis/4483384 to your computer and use it in GitHub Desktop.
Save mrmichalis/4483384 to your computer and use it in GitHub Desktop.
#!/bin/bash
cd /home/$1/backups/
mkdir mysql
suffix=$(date +%y%m%d)
MYSQL="$(which mysql)"
databases="$($MYSQL -u $1 -p$2 -Bse ‘show databases’)"
for database in $databases
do
echo "Processing database $database"
mysqldump –opt -u$1 -p$2 ${database} > mysql/${database}.$suffix.sql
done
tar -cf archives/mysql_backup.$suffix.tar mysql/*
rm -r mysql/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment