Commit ca88cf90 authored by Nicolas Wavrant's avatar Nicolas Wavrant

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
parent f1943c74
...@@ -150,7 +150,7 @@ command = grep parts ${buildout:develop-eggs-directory}/slapos.cookbook.egg-link ...@@ -150,7 +150,7 @@ command = grep parts ${buildout:develop-eggs-directory}/slapos.cookbook.egg-link
[mariadb-resiliency-after-import-script] [mariadb-resiliency-after-import-script]
recipe = slapos.recipe.build:download recipe = slapos.recipe.build:download
url = ${:_profile_base_location_}/template/instance-mariadb-resiliency-after-import-script.sh.in url = ${:_profile_base_location_}/template/instance-mariadb-resiliency-after-import-script.sh.in
md5sum = b32d9ee1cb85f85d8d2f2b58f58459f1 md5sum = 79109ae720d5471cb2dd15e63fdf4dcf
mode = 755 mode = 755
[template-mariadb] [template-mariadb]
......
...@@ -32,11 +32,16 @@ fi ...@@ -32,11 +32,16 @@ fi
echo "Deleting existing database..." echo "Deleting existing database..."
rm -r $mariadb_data_directory/* >/dev/null 2>&1 || true rm -r $mariadb_data_directory/* >/dev/null 2>&1 || true
echo "Adapting binlog database to new paths..." # $binlog_path can be empty if incremental_backup_retention_days <= -1
new_binlog_directory="$(dirname $binlog_path)" if [ -n "$binlog_path" ]; then
binlog_index_file="$new_binlog_directory/binlog.index" new_binlog_directory="$(dirname $binlog_path)"
old_binlog_directory="$(dirname $(head -n 1 $binlog_index_file))" binlog_index_file="$new_binlog_directory/binlog.index"
sed -e "s|$old_binlog_directory|$new_binlog_directory|g" $binlog_index_file > $binlog_index_file 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..." echo "Starting mariadb..."
# XXX hardcoded # XXX hardcoded
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment