BACKUP_DIR="/root/bazy"
MYSQL=mysql
MYSQLDUMP=mysqldump
$MYSQL -s -r -e 'show databases' |
while read db; do
$MYSQLDUMP $db > $BACKUP_DIR/${db}.sql;
done
----
TIMESTAMP=$(date +"%F")
BACKUP_DIR="/backup/mysql/$TIMESTAMP"
MYSQL_USER="root"
MYSQL=/usr/bin/mysql
MYSQL_PASSWORD="zrPi!COW"
MYSQLDUMP=/usr/bin/mysqldump
mkdir -p "$BACKUP_DIR"
databases=`$MYSQL --user=$MYSQL_USER -p$MYSQL_PASSWORD -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema|performance_schema)"`
for db in $databases; do
$MYSQLDUMP --force --opt --user=$MYSQL_USER -p$MYSQL_PASSWORD --databases $db | gzip > "$BACKUP_DIR/mysql/$db.gz"
done
Brak komentarzy:
Prześlij komentarz