Commit 05bdceb9 authored by Julien Muchembled's avatar Julien Muchembled

slaprunner: code simplification

parent 6bcfa760
...@@ -30,7 +30,7 @@ md5sum = 7a879739afe55320ee96409bcc8a52ab ...@@ -30,7 +30,7 @@ md5sum = 7a879739afe55320ee96409bcc8a52ab
[template-runner-export-script] [template-runner-export-script]
filename = template/runner-export.sh.jinja2 filename = template/runner-export.sh.jinja2
md5sum = 5877e70b2bd5cfe06aff793125f65d6a md5sum = d9b110db2a35c88c9eb8f87c2d2cad21
[instance-runner-export] [instance-runner-export]
filename = instance-runner-export.cfg.in filename = instance-runner-export.cfg.in
......
...@@ -104,34 +104,32 @@ fi ...@@ -104,34 +104,32 @@ fi
# Check that export didn't happen during backup of instances # Check that export didn't happen during backup of instances
tmp_backup_sum=$(mktemp -p "$tmp_directory") tmp_backup_sum=$(mktemp -p "$tmp_directory")
tmp_filtered_signature=$(mktemp -p "$tmp_directory")
remove_tmp_files () { remove_tmp_files () {
rm "$tmp_backup_sum" "$tmp_filtered_signature" rm "$tmp_backup_sum"
} }
trap remove_tmp_files EXIT trap remove_tmp_files EXIT
cd {{ directory['backup'] }}
# Wait a little to increase the probability to detect an ongoing backup.
sleep 5
# Getting files from runner backup directory, as instance backup files may be # Getting files from runner backup directory, as instance backup files may be
# explicitely excluded from the backup, using the srv/exporter.exclude # explicitely excluded from the backup, using the srv/exporter.exclude
backup_directory_path="$tmp_directory/backup_files.txt" find -path "./runner/instance/slappart*/srv/backup/*" -type f -print0 |
cd {{ directory['backup'] }} xargs -r0 sha256sum | sort -k 66 > "$tmp_backup_sum"
find . -path "./runner/instance/slappart*/srv/backup/*" -type f -print0 > $backup_directory_path
# If no backup found, it's over # If no backup found, it's over
if [ ! -s "$backup_directory_path" ]; then if [ ! -s "$tmp_backup_sum" ]; then
exit 0 exit 0
fi fi
sleep 5
cat $backup_directory_path | xargs -0 sha256sum | sort -k 66 > "$tmp_backup_sum"
rm $backup_directory_path
egrep "instance/slappart.*/srv/backup/" "$backup_directory/backup.signature" > "$tmp_filtered_signature"
# If the diff fails, then the notifier will restart this script # If the diff fails, then the notifier will restart this script
if diff "$tmp_backup_sum" "$tmp_filtered_signature"; then grep "instance/slappart.*/srv/backup/" "$backup_directory/backup.signature" |
exit 0 diff "$tmp_backup_sum" - || {
fi echo "ERROR: Some backups are not consistent, exporter should be re-run."
echo "ERROR: Some backups are not consistent, exporter should be re-run." echo "Let's sleep {{ backup_wait_time }} minutes, to let the backup end..."
echo "Let's sleep {{ backup_wait_time }} minutes, to let the backup end..." sleep {{ backup_wait_time }}m
sleep {{ backup_wait_time }}m exit 1
exit 1 }
  • This is a follow-up of the discussion on 783d0ab0

    However, it looks overkill to checksum the data in order to detect changes. I'd rather look at change times (which are updated on any metadata/data change), using find -cmin -1.

    /cc @Nicolas @alain.takoudjou

  • Thank you for the commit.

    However, it looks overkill to checksum the data in order to detect changes. I'd rather look at change times (which are updated on any metadata/data change), using find -cmin -1.

    yes, this part can take more than 5 minutes on bigger instances and some instances has more than 20k files to verify.

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