From 7b420502628f933f1d4680b119facf834e9b2264 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Fri, 6 Oct 2023 11:55:17 +0200 Subject: [PATCH] mysqldump params can be customized in jobs/env --- jobhelper.sh | 2 ++ jobs/env_defaults | 21 +++++++++++++++++++++ plugins/localdump/mysql.sh | 12 +++++------- 3 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 jobs/env_defaults diff --git a/jobhelper.sh b/jobhelper.sh index d2c247c..5a5f2eb 100755 --- a/jobhelper.sh +++ b/jobhelper.sh @@ -15,6 +15,7 @@ # 2022-10-07 ah v1.4 unescape regex with space to prevent "grep: warning: stray \ before white space" # 2023-03-17 ah v1.5 ignore required user on MS windows; source jobs/env if it exists; use varaiable FQDN # 2023-04-12 ah v1.6 add desktop notification +# 2023-10-06 v1.7 source jobs/env_defaults # ================================================================================ @@ -43,6 +44,7 @@ STORAGEFILE="${DIR_JOBS}/transfer.job" function j_init(){ j_banner + . "${DIR_JOBS}/env_defaults" if [ -r "${DIR_JOBS}/env" ]; then echo "INFO: loading custom environment ${DIR_JOBS}/env" diff --git a/jobs/env_defaults b/jobs/env_defaults new file mode 100644 index 0000000..322878b --- /dev/null +++ b/jobs/env_defaults @@ -0,0 +1,21 @@ +#!/bin/bash +# ---------------------------------------------------------------------- +# +# DEFAULTS !!! Do not edit this file !!! +# Overide customizations in file "env" (maybe copy env.dist to env first) +# +# ---------------------------------------------------------------------- + +# ---------------------------------------------------------------------- +# Localdump +# ---------------------------------------------------------------------- + +# mysql +LD_MYSQL_DUMP_PARAMS="--opt \ + --default-character-set=utf8 \ + --flush-logs \ + --single-transaction \ + --no-autocommit \ + " + +# ---------------------------------------------------------------------- \ No newline at end of file diff --git a/plugins/localdump/mysql.sh b/plugins/localdump/mysql.sh index 2fad72e..8b1c866 100755 --- a/plugins/localdump/mysql.sh +++ b/plugins/localdump/mysql.sh @@ -15,6 +15,7 @@ # 2022-03-17 v2.2 WIP: add lines with prefix __DB__ # 2022-03-21 v2.3 Check if the created dump contains "insert" # 2022-03-24 v2.4 On empty dumps: detect if source db is empty too +# 2023-10-06 v2.5 mysqldump params can be customized in jobs/env # ================================================================================ if [ -z "$LOCALDUMP_LOADED" ]; then @@ -78,6 +79,9 @@ function mysql.db.create(){ # dump [database] --> [file] # dump a single database into given file +# +# global LD_MYSQL_DUMP_PARAMS string parameters from file jobs/env_defaults +# # param string name of database to dump # param string name of output file function mysql.db.dump(){ @@ -85,13 +89,7 @@ function mysql.db.dump(){ local _dbname=$1 local _dumpfile=$2 - mysqldump --opt \ - --default-character-set=utf8 \ - --flush-logs \ - --single-transaction \ - --no-autocommit \ - --result-file="$_dumpfile" \ - "$_dbname" 2>&1 + mysqldump $LD_MYSQL_DUMP_PARAMS --result-file="$_dumpfile" "$_dbname" 2>&1 fetchrc >/dev/null if [ $myrc -eq 0 ]; then -- GitLab