From 196a4b41f215c62a12d017ab65e854fe4a9fff9f Mon Sep 17 00:00:00 2001 From: vincent Date: Fri, 22 Jun 2018 16:33:59 +0200 Subject: [PATCH 1/2] Prise en charge du dump des bases mariadb par schedule et bareos + copier des dump sur le partage nfs --- eole-mariadb.mk | 4 +++- schedule_config/config.sh | 7 +++++++ schedule_extra/01_mysql.xml | 18 ++++++++++++++++++ schedule_scripts/mysql | 27 +++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 schedule_config/config.sh create mode 100644 schedule_extra/01_mysql.xml create mode 100644 schedule_scripts/mysql diff --git a/eole-mariadb.mk b/eole-mariadb.mk index 7756e21..ca6673e 100644 --- a/eole-mariadb.mk +++ b/eole-mariadb.mk @@ -1 +1,3 @@ -creolefuncs_DATA_DIR := $(DESTDIR)/usr/share/creole/funcs \ No newline at end of file +creolefuncs_DATA_DIR := $(DESTDIR)/usr/share/creole/funcs +schedule_extra_DATA_DIR := $(DESTDIR)/usr/share/eole/creole/extra/schedule/ +schedule_config_DATA_DIR := $(DESTDIR)/usr/share/eole/schedule/ diff --git a/schedule_config/config.sh b/schedule_config/config.sh new file mode 100644 index 0000000..2562ef3 --- /dev/null +++ b/schedule_config/config.sh @@ -0,0 +1,7 @@ +# Configuration commune aux scripts schedule +# Configuration de base modifiée pour copier dans le partage nfs plutôt que /home + +SAVDIR=/mnt/sauvegardes/ +# pour que l'affichage de [ ok ] soit ok +export TERM='dumb' +umask 0077 diff --git a/schedule_extra/01_mysql.xml b/schedule_extra/01_mysql.xml new file mode 100644 index 0000000..e0327fa --- /dev/null +++ b/schedule_extra/01_mysql.xml @@ -0,0 +1,18 @@ + + + + + + + daily + + + + + + non + none + daily + + + diff --git a/schedule_scripts/mysql b/schedule_scripts/mysql new file mode 100644 index 0000000..06b3ff9 --- /dev/null +++ b/schedule_scripts/mysql @@ -0,0 +1,27 @@ +#!/bin/bash + +set -e + +DESC="Exportation des bases MySQL" + +. /usr/share/eole/schedule/config.sh + +MYSQLSAVDIR=$SAVDIR/sql +OPTION="--lock-tables" + +rm -f $MYSQLSAVDIR/*.sql +mkdir -p $MYSQLSAVDIR + +CMD="mysql --defaults-file=/etc/mysql/mariadb.cnf -e 'show databases' | grep -v '^Database$'" +DATABASES=$(CreoleRun "$CMD" mysql) +for databasename in $DATABASES; do + case "$databasename" in + information_schema|performance_schema|bareos) + continue + ;; + *) + CMD="mysqldump --defaults-file=/etc/mysql/mariadb.cnf --databases $databasename --flush-privileges --create-options -Q -c $OPTION 2>/dev/null" + CreoleRun "$CMD" mysql > $MYSQLSAVDIR/$databasename.sql + ;; + esac +done From f832feeae33d1cb055380dfb84980400ab171abf Mon Sep 17 00:00:00 2001 From: vincent Date: Fri, 22 Jun 2018 16:44:19 +0200 Subject: [PATCH 2/2] ajout d'une condition pour pouvoir activer ou non la sauveagrde de mariadb --- dicos/25_bdd_server.xml | 3 +++ schedule_extra/01_mysql.xml | 1 + 2 files changed, 4 insertions(+) diff --git a/dicos/25_bdd_server.xml b/dicos/25_bdd_server.xml index c14f991..6a0431f 100644 --- a/dicos/25_bdd_server.xml +++ b/dicos/25_bdd_server.xml @@ -30,6 +30,9 @@ non + + non + diff --git a/schedule_extra/01_mysql.xml b/schedule_extra/01_mysql.xml index e0327fa..cd4118c 100644 --- a/schedule_extra/01_mysql.xml +++ b/schedule_extra/01_mysql.xml @@ -11,6 +11,7 @@ non + dbEnableBackup none daily