diff --git a/stack/erp5/buildout.cfg b/stack/erp5/buildout.cfg index 8249d80d76ee2a50a15fa1a225eace771e646404..d567adc5ed3d4ad3ef6214b053f9a670956f8e34 100644 --- a/stack/erp5/buildout.cfg +++ b/stack/erp5/buildout.cfg @@ -301,7 +301,7 @@ md5sum = 28db329061ae863367a76951b9b1152c [template-zeo] < = download-base filename = instance-zeo.cfg.in -md5sum = 5b8639e77217d4fbdee19338a25b6128 +md5sum = cc91f5a4778153dc1d34398b9a80150d [template-zope] < = download-base diff --git a/stack/erp5/instance-zeo.cfg.in b/stack/erp5/instance-zeo.cfg.in index 194fc3cc386c27f8e2182b7f6e446b2efbc83c66..ef2e57b88d28d86ae913b976699f96472381375a 100644 --- a/stack/erp5/instance-zeo.cfg.in +++ b/stack/erp5/instance-zeo.cfg.in @@ -125,12 +125,57 @@ recipe = collective.recipe.template input = inline: {{ default_zodb_path }}/** output = ${directory:srv}/exporter.exclude +[{{ section("resiliency-after-import-script") }}] +# Generate after import script used by importer instance of webrunner +recipe = collective.recipe.template +input = inline: #!/bin/sh + # DO NOT RUN THIS SCRIPT ON PRODUCTION INSTANCE + # OR ZODB DATA WILL BE ERASED. + + # This script will restore the repozo backup to the real + # zodb location. It is launched by the clone (importer) instance of webrunner + # in the end of the import script. + + # Depending on the output, it will create a file containing + # the status of the restoration (success or failure). + zodb_directory="${directory:zodb}" + zodb_backup_directory="{{ default_backup_path }}" + repozo="${tidstorage:repozo-binary}" + EXIT_CODE=0 + {% for family, zodb in zodb_dict.iteritems() -%} + {% for name, zodb in zodb -%} + {% set zeo_section_name = 'zeo-' ~ family %} + storage_name="{{ name }}" + zodb_path="$storage_name.fs" + pid_file={{ "${" ~ zeo_section_name ~ ":pid-path}" }} + if [ -e "$pid_file" ]; then + pid=$(cat $pid_file) > /dev/null 2>&1 + if kill -0 "$pid"; then + echo "Zeo is already running with pid $pid. Aborting." + exit 1 + fi + fi + echo "Removing $zodb_path..." + echo "Restoring $storage_name into $zodb_path..." + $repozo --recover --output="$zodb_directory/$zodb_path" --repository="$zodb_backup_directory/$storage_name" + CURRENT_EXIT_CODE=$? + if [ ! "$CURRENT_EXIT_CODE"="0" ]; then + EXIT_CODE="$CURRENT_EXIT_CODE" + echo "$storage_name Backup restoration failed." + fi + {% endfor -%} + {% endfor -%} + exit $EXIT_CODE +output = ${directory:srv}/runner-import-restore +mode = 755 + [directory] recipe = slapos.cookbook:mkdirectory bin = ${buildout:directory}/bin etc = ${buildout:directory}/etc services = ${:etc}/run promises = ${:etc}/promise +srv = ${buildout:directory}/srv var = ${buildout:directory}/var log = ${:var}/log run = ${:var}/run