sauvegardes/bin/dump-msql

19 lines
845 B
Plaintext
Raw Permalink Normal View History

2023-03-20 23:43:59 +01:00
#!/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