sauvegardes/Plan Borg/bin/dump-msql

19 lines
845 B
Bash
Executable File

#!/bin/bash
DUMP_DIR="/var/backups/dumps/"
mkdir -p "$DUMP_DIR"
chmod go-rwx "$DUMP_DIR"
if [ -x /usr/bin/mariadb-dump ]; then
#
DATABASES=$(mysql --defaults-file=/etc/mysql/debian.cnf -B -N --execute="SHOW DATABASES" | grep -v 'lost+found\|performance_schema\|information_schema')
echo "Databases: $DATABASES"
for DATABASE in $DATABASES ; do
echo "Dumping database: $DATABASE"
/usr/bin/mariadb-dump --defaults-file=/etc/mysql/debian.cnf --single-transaction --quick --events $DATABASE | bzip2 - > $DUMP_DIR/$DATABASE-msql.sql.bz2
done
else
echo "DMBS MariaDB not detected."
fi