From 0119429ac5588fa5aaa3b75a3634a754d617d3e1 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 1 May 2024 02:18:19 +0000 Subject: [PATCH] Bug 36435: Catch harmless errors in koha-dump MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit tar has exit status 1 if any file has changed while being read, which is likely to happen as the logfiles are included. this patch will catch these harmless errors so that koha-dump will still return a success code. Test plan: 1. Create a number of backups and edit their modify time to being older than 2 days 2. run the koha-run-backups script and try and write to one of the files it includes while it's being backed up (you'll trigger a warning from tar saying the file changed as it was being read) 3. verify that the older backups are not being cleaned up and deleted despite new backups being made. 4. Apply this patch 5. Complete steps 1-2 again and then go and look to see if the older backups are being deleted. Sponsored-by: Catalyst IT Signed-off-by: David Nind Co-authored-by: Michał Kula <148193449+mkibp@users.noreply.github.com> Signed-off-by: Michał Kula <148193449+mkibp@users.noreply.github.com> Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer --- debian/scripts/koha-dump | 45 +++++++++++++++++++++++----------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/debian/scripts/koha-dump b/debian/scripts/koha-dump index f58c4b2022..6ed0f1b683 100755 --- a/debian/scripts/koha-dump +++ b/debian/scripts/koha-dump @@ -124,30 +124,37 @@ dump_instance() output="$output to $metadump" [ "$quiet" = "no" ] && echo "$output" - if [ "$exclude_logs" = "yes" ]; then - tar -czf "$metadump" -C / $excludes \ - "etc/koha/sites/$name" \ - "etc/apache2/sites-available/$instancefile" \ - "etc/apache2/sites-enabled/$instancefile" \ - "var/lib/koha/$name" \ - $uploaded_files_dir \ - $uploaded_temp_files_dir + # tar has exit status 1 if any file has changed while being read, + # which is likely to happen as the logfiles are included. + set +e - chown "root:$name-koha" "$metadump" - chmod g+r "$metadump" + if [ "$exclude_logs" = "yes" ]; then + tar -czf "$metadump" -C / $excludes \ + "etc/koha/sites/$name" \ + "etc/apache2/sites-available/$instancefile" \ + "etc/apache2/sites-enabled/$instancefile" \ + "var/lib/koha/$name" \ + $uploaded_files_dir \ + $uploaded_temp_files_dir else - tar -czf "$metadump" -C / $excludes \ - "etc/koha/sites/$name" \ - "etc/apache2/sites-available/$instancefile" \ - "etc/apache2/sites-enabled/$instancefile" \ - "var/lib/koha/$name" \ - "var/log/koha/$name" \ - $uploaded_files_dir \ - $uploaded_temp_files_dir + tar -czf "$metadump" -C / $excludes \ + "etc/koha/sites/$name" \ + "etc/apache2/sites-available/$instancefile" \ + "etc/apache2/sites-enabled/$instancefile" \ + "var/lib/koha/$name" \ + "var/log/koha/$name" \ + $uploaded_files_dir \ + $uploaded_temp_files_dir + fi + + if [ "$?" != "1" -a "$?" != "0" ]; then + exit $? + fi + + set -e chown "root:$name-koha" "$metadump" chmod g+r "$metadump" - fi [ "$quiet" = "no" ] && echo "Done." fi -- 2.39.5