Created
August 22, 2013 10:12
-
-
Save simonda86/6305487 to your computer and use it in GitHub Desktop.
MySQL Backup script for all databases
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/bash | |
user="" | |
password="" | |
host="" | |
backup_path="/path/to/your/home/_backup/mysql" | |
date=$(date +"%d-%b-%Y") | |
# Get list of databases | |
databases=$(mysql --user=$user --password=$password -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema)") | |
# Create folder using date | |
mkdir $backup_path/$date | |
# Create dumps for each database | |
for db in $databases | |
do | |
mysqldump --user=$user --password=$password --host=$host $db > $backup_path/$date/$db.sql | |
done |
what if input of password should be hidden. How to do that?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use --routines