-
-
Save ScribeOfGoD/e0fa6b19e45c3573a5d5229dc76f0b0d to your computer and use it in GitHub Desktop.
MySQL Backup script for all databases
This file contains 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment