From 1be07999ca2d85470e02ea15725a05bab62f36b8 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 1 May 2024 02:18:19 +0000 Subject: [PATCH] Bug 36435: [alternative] Catch harmless errors in koha-dump 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 --- debian/scripts/koha-dump | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/debian/scripts/koha-dump b/debian/scripts/koha-dump index d9946073009..50af5888ed6 100755 --- a/debian/scripts/koha-dump +++ b/debian/scripts/koha-dump @@ -123,6 +123,10 @@ dump_instance() output="$output to $metadump" [ "$quiet" = "no" ] && echo "$output" + # 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 + tar -czf "$metadump" -C / $excludes \ "etc/koha/sites/$name" \ "etc/apache2/sites-available/$instancefile" \ @@ -132,6 +136,12 @@ dump_instance() $uploaded_files_dir \ $uploaded_temp_files_dir + if [ "$?" != "1" -a "$?" != "0" ]; then + exit $? + fi + + set -e + chown "root:$name-koha" "$metadump" chmod g+r "$metadump" -- 2.39.2