Bug 36435: 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
Signed-off-by: David Nind <david@davidnind.com>
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 <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit 0119429ac5)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Aleisha Amohia 2024-05-01 02:18:19 +00:00 committed by Lucas Gass
parent 464978912b
commit c46e5c782d
1 changed files with 26 additions and 19 deletions

View File

@ -124,30 +124,37 @@ 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
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
chown "root:$name-koha" "$metadump"
chmod g+r "$metadump"
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