From ca88cf90a1d9c4f3866bb9c5d8c3578d84e5ed58 Mon Sep 17 00:00:00 2001 From: Nicolas Wavrant <nicolas.wavrant@nexedi.com> Date: Tue, 24 Jan 2017 18:40:53 +0100 Subject: [PATCH] erp5: resiliency-after-import script of mariadb shouldn't fail if there is no binlog If there is no binlog in srv/backup/mariadb-incremental (ie : the parameter incremental_backup_retention_days is set to -1), then the import script fails. This should not happen as this script just updates some inline paths. This commit just add a correct check on variables and files existence --- stack/erp5/buildout.cfg | 2 +- ...e-mariadb-resiliency-after-import-script.sh.in | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/stack/erp5/buildout.cfg b/stack/erp5/buildout.cfg index cbb3c0032..72439f55e 100644 --- a/stack/erp5/buildout.cfg +++ b/stack/erp5/buildout.cfg @@ -150,7 +150,7 @@ command = grep parts ${buildout:develop-eggs-directory}/slapos.cookbook.egg-link [mariadb-resiliency-after-import-script] recipe = slapos.recipe.build:download url = ${:_profile_base_location_}/template/instance-mariadb-resiliency-after-import-script.sh.in -md5sum = b32d9ee1cb85f85d8d2f2b58f58459f1 +md5sum = 79109ae720d5471cb2dd15e63fdf4dcf mode = 755 [template-mariadb] diff --git a/stack/erp5/template/instance-mariadb-resiliency-after-import-script.sh.in b/stack/erp5/template/instance-mariadb-resiliency-after-import-script.sh.in index da018bb73..3c572989a 100644 --- a/stack/erp5/template/instance-mariadb-resiliency-after-import-script.sh.in +++ b/stack/erp5/template/instance-mariadb-resiliency-after-import-script.sh.in @@ -32,11 +32,16 @@ fi echo "Deleting existing database..." rm -r $mariadb_data_directory/* >/dev/null 2>&1 || true -echo "Adapting binlog database to new paths..." -new_binlog_directory="$(dirname $binlog_path)" -binlog_index_file="$new_binlog_directory/binlog.index" -old_binlog_directory="$(dirname $(head -n 1 $binlog_index_file))" -sed -e "s|$old_binlog_directory|$new_binlog_directory|g" $binlog_index_file > $binlog_index_file +# $binlog_path can be empty if incremental_backup_retention_days <= -1 +if [ -n "$binlog_path" ]; then + new_binlog_directory="$(dirname $binlog_path)" + binlog_index_file="$new_binlog_directory/binlog.index" + if [ -e "$binlog_index_file" ]; then + echo "Adapting binlog database to new paths..." + old_binlog_directory="$(dirname $(head -n 1 $binlog_index_file))" + sed -e "s|$old_binlog_directory|$new_binlog_directory|g" $binlog_index_file > $binlog_index_file + fi +fi echo "Starting mariadb..." # XXX hardcoded -- 2.30.9