From 06a118f1081da3e53a339e5577b2aec41c269f84 Mon Sep 17 00:00:00 2001
From: Marion Durand <marion.durand@biblibre.com>
Date: Thu, 21 Oct 2021 08:00:21 +0000
Subject: [PATCH] Bug 21903: koha-dump can export uploaded and temporary
 uploaded files

Minor improvment on display.
Solve the error message if the folder for uploaded temp files
doesn't exist.

Sponsored-by: Orex

Test plan:
- Apply the patch
- Try using koha-dump without any option
- Try using koha-dump with --uploaded_files
- Try using koha-dump with --uploaded_temp_files
- Try using koha-dump with both of the options above

Expected results: the .tar.gz dump will include uploaded and/or temporary
uploaded files if requested.
Change message and solve the error message if no temporary folder
---
 debian/scripts/koha-dump | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/debian/scripts/koha-dump b/debian/scripts/koha-dump
index 62c1c57433..399eb8618f 100755
--- a/debian/scripts/koha-dump
+++ b/debian/scripts/koha-dump
@@ -97,7 +97,7 @@ dump_instance()
 
         # Dump configs, logs, etc.
         metadump="$backupdir/$name-$date.tar.gz"
-        [ "$quiet" = "no" ] && echo "* configs, files, logs to $metadump"
+        output="* configs, logs"
 
         if [ "$exclude_indexes" = "yes" ]; then
             excludes="--exclude=var/lib/koha/$name/biblios \
@@ -107,14 +107,22 @@ dump_instance()
         if [ "$uploaded_files" = "yes" ]; then
             # Remove leading /
             uploaded_files_dir=$(echo $(get_upload_path $name) | cut -c 2-)
+            output="$output, uploaded files"
         fi
 
         if [ "$uploaded_temp_files" = "yes" ]; then
             # Remove leading /
             tempdir=$(echo $(get_tmp_path $name) | cut -c 2-)
             uploaded_temp_files_dir="$tempdir/koha_${name}_upload"
+            if ! [ -d /$uploaded_temp_files_dir ]; then
+                mkdir /$uploaded_temp_files_dir
+            fi
+            output="$output, uploaded temporary files"
         fi
 
+        output="$output to $metadump"
+        [ "$quiet" = "no" ] && echo "$output"
+
         tar -czf "$metadump" -C / $excludes \
             "etc/koha/sites/$name" \
             "etc/apache2/sites-available/$instancefile" \
-- 
2.17.1