From 44629b4587bbba9d93091bc528839bdd4314994d Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Fri, 7 Jun 2019 14:47:57 +0200 Subject: [PATCH 1/5] extract backup with mariabackup --- schedule/scripts/mariadb | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/schedule/scripts/mariadb b/schedule/scripts/mariadb index feb407e..b9b8ba5 100644 --- a/schedule/scripts/mariadb +++ b/schedule/scripts/mariadb @@ -12,16 +12,6 @@ OPTION="--lock-tables" rm -f $MYSQLSAVDIR/*.sql || true mkdir -p $MYSQLSAVDIR -DATABASES=$(mysql --defaults-file=/etc/mysql/debian.cnf -e 'show databases' | grep -v '^Database$') -for databasename in $DATABASES; do - case "$databasename" in - information_schema|performance_schema|bareos) - continue - ;; - *) - mysqldump --defaults-file=/etc/mysql/debian.cnf --databases $databasename --flush-privileges --create-options -Q -c $OPTION > $MYSQLSAVDIR/$databasename.sql - ;; - esac -done +mariabackup --defaults-file=/etc/mysql/debian.cnf --backup --target-dir=$MYSQLSAVDIR exit 0 From 52eadb6bf157db7f299357d5cbe39324495b3df4 Mon Sep 17 00:00:00 2001 From: Philippe Caseiro Date: Thu, 19 Nov 2020 10:15:32 +0100 Subject: [PATCH 2/5] Fix schedule backup script --- schedule/scripts/mariadb | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/schedule/scripts/mariadb b/schedule/scripts/mariadb index b9b8ba5..7a83ea4 100644 --- a/schedule/scripts/mariadb +++ b/schedule/scripts/mariadb @@ -9,9 +9,11 @@ DESC="Exportation des bases MariaDB" MYSQLSAVDIR=$SAVDIR/sql OPTION="--lock-tables" -rm -f $MYSQLSAVDIR/*.sql || true -mkdir -p $MYSQLSAVDIR +if [[ -d ${MYSQLSAVDIR} ]] +then + rm -rf ${MYSQLSAVDIR} + mkdir -p ${MYSQLSAVDIR} +fi mariabackup --defaults-file=/etc/mysql/debian.cnf --backup --target-dir=$MYSQLSAVDIR - -exit 0 +exit $? From 0ab65611b0cd95a5b140ee30c1aa76edfeb92b10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Gourv=C3=A9nec?= Date: Wed, 26 Jul 2023 17:05:42 +0200 Subject: [PATCH 3/5] =?UTF-8?q?Ajout=20scripts=20pour=20voir=20et=20r?= =?UTF-8?q?=C3=A9duire=20la=20taille=20des=20tables=20hydra?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/get_tables_sizes.sh | 25 +++++++++++++++++++ scripts/optimize_hydra | 49 +++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100755 scripts/get_tables_sizes.sh create mode 100755 scripts/optimize_hydra diff --git a/scripts/get_tables_sizes.sh b/scripts/get_tables_sizes.sh new file mode 100755 index 0000000..3887e84 --- /dev/null +++ b/scripts/get_tables_sizes.sh @@ -0,0 +1,25 @@ +#!/bin/bash + +( +mysql --defaults-file=/etc/mysql/debian.cnf hydra < Date: Mon, 4 Sep 2023 16:05:22 +0200 Subject: [PATCH 4/5] =?UTF-8?q?Ajout=20d'un=20script=20schedule=20pour=20r?= =?UTF-8?q?=C3=A9duire=20la=20taille=20de=20la=20bdd=20hydra?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Extraction des données de la veille puis suppression des données --- schedule/extra/01_extract_hydra.xml | 20 +++++++++ schedule/scripts/extract_hydra_logs | 69 +++++++++++++++++++++++++++++ 2 files changed, 89 insertions(+) create mode 100644 schedule/extra/01_extract_hydra.xml create mode 100644 schedule/scripts/extract_hydra_logs diff --git a/schedule/extra/01_extract_hydra.xml b/schedule/extra/01_extract_hydra.xml new file mode 100644 index 0000000..188e951 --- /dev/null +++ b/schedule/extra/01_extract_hydra.xml @@ -0,0 +1,20 @@ + + + + + + + daily + + + + + + + non + dbEnableBackup + none + daily + + + diff --git a/schedule/scripts/extract_hydra_logs b/schedule/scripts/extract_hydra_logs new file mode 100644 index 0000000..f5be79b --- /dev/null +++ b/schedule/scripts/extract_hydra_logs @@ -0,0 +1,69 @@ +#!/bin/bash + +DESC="Extraction des logs de connexion de la base Hydra" + +. /usr/share/eole/schedule/config.sh + +file_date=$(date '+%Y%m%d' -d@$(($(date +%s) -3600*24))) # Date pour le format des noms de fichier +today=$(date '+%Y-%m-%d') # Date de fin de requête +yesterday=$(date '+%Y-%m-%d' -d@$(($(date +%s) -3600*24))) # Date de début de requête +exit_status=0 + +echo "Begin date: $(date)" + +mysql --defaults-file=/etc/mysql/debian.cnf hydra <= '${yesterday} 00:00:00' and requested_at < '${today} 00:00:00' + order by requested_at ; +EOF +(( exit_status = exit_status || $? )) + +mysql --defaults-file=/etc/mysql/debian.cnf hydra <= '${yesterday} 00:00:00' and requested_at < '${today} 00:00:00' + order by requested_at ; +EOF +(( exit_status = exit_status || $? )) + +mysql --defaults-file=/etc/mysql/debian.cnf hydra <= '${yesterday} 00:00:00' and requested_at < '${today} 00:00:00' + order by requested_at ; +EOF +(( exit_status = exit_status || $? )) + +# Tags must be 32 char long max (otherwise, default fwd template truncates it) +logger -f /var/lib/mysql/hydra/access-${file_date} -t mariadb_hydra-access-${file_date} +logger -f /var/lib/mysql/hydra/consent-request-handled-${file_date} -t mariadb_hydra-consreq-h-${file_date} +logger -f /var/lib/mysql/hydra/authentication-request-${file_date} -t mariadb_hydra-authreq-${file_date} + +# Remove log files older than 7 days (already saved on the NAS) +find /var/lib/mysql/hydra/ -name 'access-*' -type f -mtime +7 -exec rm -vf {} \; +find /var/lib/mysql/hydra/ -name 'consent-request-handled-*' -type f -mtime +7 -exec rm -vf {} \; +find /var/lib/mysql/hydra/ -name 'authentication-request-*' -type f -mtime +7 -exec rm -vf {} \; + +find /var/log/rsyslog/local/mariadb_hydra/ -name 'access-*' -type f -mtime +7 -exec rm -vf {} \; +find /var/log/rsyslog/local/mariadb_hydra/ -name 'consreq-h-*' -type f -mtime +7 -exec rm -vf {} \; +find /var/log/rsyslog/local/mariadb_hydra/ -name 'authreq-*' -type f -mtime +7 -exec rm -vf {} \; + +echo "End date: $(date)" + +exit $exit_status From eb80e522f7ae2bc9577d597747c3fb014713910a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Laurent=20Gourv=C3=A9nec?= Date: Wed, 6 Sep 2023 11:45:10 +0200 Subject: [PATCH 5/5] Renommage du script get_tables_sizes.sh en get_hydra_table_sizes Plus significatif et proche des noms des autres scripts. --- scripts/{get_tables_sizes.sh => get_hydra_table_sizes} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename scripts/{get_tables_sizes.sh => get_hydra_table_sizes} (100%) diff --git a/scripts/get_tables_sizes.sh b/scripts/get_hydra_table_sizes similarity index 100% rename from scripts/get_tables_sizes.sh rename to scripts/get_hydra_table_sizes