#!/bin/bash
user="root"
password="your root user password"
host="localhost"
backup_path="backup path"
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
user="root"
password="your root user password"
host="localhost"
backup_path="backup path"
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
0 comments:
Post a Comment