Philippe Caseiro 1 year ago
parent
commit
7a99473352
5 changed files with 59 additions and 1 deletions
  1. 3
    0
      dicos/25_bdd_server.xml
  2. 3
    1
      eole-mariadb.mk
  3. 7
    0
      schedule_config/config.sh
  4. 19
    0
      schedule_extra/01_mysql.xml
  5. 27
    0
      schedule_scripts/mysql

+ 3
- 0
dicos/25_bdd_server.xml View File

@@ -30,6 +30,9 @@
30 30
            <variable name="dbEnable" type='oui/non' description='Activer le serveur de base de données MariaDB'>
31 31
               <value>non</value>
32 32
            </variable>
33
+           <variable name="dbEnableBackup" type='oui/non' description='Activer la sauvegarde sur le serveur de base de données MariaDB'>
34
+              <value>non</value>
35
+           </variable>
33 36
         </family>
34 37
         <family name="Database">
35 38
             <variable name='dbEnableCluster' type='oui/non' description="Activer la mise en grappe MariaDB Galera ?">

+ 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

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

@@ -0,0 +1,19 @@
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 type='eole' name='condition_1'>dbEnableBackup</param>
15
+            <param name='match'>none</param>
16
+            <param name='mismatch'>daily</param>
17
+        </fill>
18
+    </constraints>
19
+</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