Browse Source

Prise en charge du dump des bases mariadb par schedule et bareos + copier des dump sur le partage nfs

2.6.2/master^2
Vincent Febvre 1 year ago
parent
commit
196a4b41f2
4 changed files with 55 additions and 1 deletions
  1. 3
    1
      eole-mariadb.mk
  2. 7
    0
      schedule_config/config.sh
  3. 18
    0
      schedule_extra/01_mysql.xml
  4. 27
    0
      schedule_scripts/mysql

+ 3
- 1
eole-mariadb.mk View File

@@ -1 +1,3 @@
1
-creolefuncs_DATA_DIR := $(DESTDIR)/usr/share/creole/funcs
1
+creolefuncs_DATA_DIR := $(DESTDIR)/usr/share/creole/funcs
2
+schedule_extra_DATA_DIR := $(DESTDIR)/usr/share/eole/creole/extra/schedule/
3
+schedule_config_DATA_DIR := $(DESTDIR)/usr/share/eole/schedule/

+ 7
- 0
schedule_config/config.sh View File

@@ -0,0 +1,7 @@
1
+# Configuration commune aux scripts schedule
2
+# Configuration de base modifiée pour copier dans le partage nfs plutôt que /home
3
+
4
+SAVDIR=/mnt/sauvegardes/
5
+# pour que l'affichage de [ ok ] soit ok
6
+export TERM='dumb'
7
+umask 0077

+ 18
- 0
schedule_extra/01_mysql.xml View File

@@ -0,0 +1,18 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+
3
+<creole>
4
+    <variables>
5
+        <family name="mysql" description="Exportation des bases de données MySQL">
6
+            <variable name="description" type="string" hidden="True"><value>Exportation des bases MySQL</value></variable>
7
+            <variable name="day" type="schedule" description="Périodicité d'exécution"><value>daily</value></variable>
8
+            <variable name="mode" type="schedulemod" hidden="True"><value>pre</value></variable>
9
+        </family>
10
+    </variables>
11
+    <constraints>
12
+        <fill name='calc_multi_condition' target='schedule.mysql.day'>
13
+            <param>non</param>
14
+            <param name='match'>none</param>
15
+            <param name='mismatch'>daily</param>
16
+        </fill>
17
+    </constraints>
18
+</creole>

+ 27
- 0
schedule_scripts/mysql View File

@@ -0,0 +1,27 @@
1
+#!/bin/bash
2
+
3
+set -e
4
+
5
+DESC="Exportation des bases MySQL"
6
+
7
+. /usr/share/eole/schedule/config.sh
8
+
9
+MYSQLSAVDIR=$SAVDIR/sql
10
+OPTION="--lock-tables"
11
+
12
+rm -f $MYSQLSAVDIR/*.sql
13
+mkdir -p $MYSQLSAVDIR
14
+
15
+CMD="mysql --defaults-file=/etc/mysql/mariadb.cnf -e 'show databases' | grep -v '^Database$'"
16
+DATABASES=$(CreoleRun "$CMD" mysql)
17
+for databasename in $DATABASES; do
18
+    case "$databasename" in
19
+        information_schema|performance_schema|bareos)
20
+            continue
21
+            ;;
22
+        *)
23
+            CMD="mysqldump --defaults-file=/etc/mysql/mariadb.cnf --databases $databasename --flush-privileges --create-options -Q -c $OPTION 2>/dev/null"
24
+            CreoleRun "$CMD" mysql > $MYSQLSAVDIR/$databasename.sql
25
+            ;;
26
+    esac
27
+done

Loading…
Cancel
Save