From 126169ef7689a5de8534357efdf6b305996cda8c Mon Sep 17 00:00:00 2001 From: Matthias Meusburger Date: Wed, 10 Apr 2019 11:38:45 +0200 Subject: [PATCH] Bug 21903: koha-dump can export uploaded and temporary uploaded files 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. --- debian/scripts/koha-dump | 20 ++++++++++++++++++-- debian/scripts/koha-functions.sh | 20 ++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/debian/scripts/koha-dump b/debian/scripts/koha-dump index ff171a0..7d25d65 100755 --- a/debian/scripts/koha-dump +++ b/debian/scripts/koha-dump @@ -44,6 +44,8 @@ $scriptname [--quiet|-q] [--include-indexes|-i] instancename1 [instancename2...] $scriptname -h|--help --exclude-indexes Include Zebra indexes on the backup. + --uploaded_files Include uploaded files. + --uploaded_temp_files Include temporary uploaded files. --quiet|-q Make the script avoid printing to STDOUT (useful for calling from another scripts). --help|-h Display this help message @@ -79,19 +81,33 @@ dump_instance() # Dump configs, logs, etc. metadump="$backupdir/$name-$date.tar.gz" - [ "$quiet" = "no" ] && echo "* configs, logs to $metadump" + [ "$quiet" = "no" ] && echo "* configs, files, logs to $metadump" if [ "$exclude_indexes" = "yes" ]; then excludes="--exclude=var/lib/koha/$name/biblios \ --exclude=var/lib/koha/$name/authorities" fi + if [ "$uploaded_files" = "yes" ]; then + # Remove leading / + uploaded_files_dir=$(echo $(get_upload_path $name) | cut -c 2-) + 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" + fi + 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" + "var/log/koha/$name" \ + $uploaded_files_dir \ + $uploaded_temp_files_dir + [ "$quiet" = "no" ] && echo "Done." } diff --git a/debian/scripts/koha-functions.sh b/debian/scripts/koha-functions.sh index 3a04db7..765d8b9 100755 --- a/debian/scripts/koha-functions.sh +++ b/debian/scripts/koha-functions.sh @@ -279,6 +279,26 @@ get_max_record_size() fi } +get_tmp_path() +{ + local instancename=$1 + local retval=$(run_safe_xmlstarlet $instancename tmp_path) + if [ "$retval" != "" ]; then + echo "$retval" + return 0 + fi +} + +get_upload_path() +{ + local instancename=$1 + local retval=$(run_safe_xmlstarlet $instancename upload_path) + if [ "$retval" != "" ]; then + echo "$retval" + return 0 + fi +} + get_tmpdir() { if [ "$TMPDIR" != "" ]; then -- 2.7.4