From 3b460c7d9e6daf367cef82047a3111c39e9209af Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Mon, 13 Jul 2020 10:25:02 -0300 Subject: [PATCH] Bug 21111: Add --exclude-indexes to koha-run-backups This patch adds a trivial switch so koha-run-backups can pass the --exclude-indexes option switch to koha-dump. This way if the sysadmin doesn't want to backup the Zebra indexes, it can be controlled by tweaking the cron definition. To test: 1. Apply this patch 2. Run: $ debian/scripts/koha-run-backups --days 2 --output /var/spool/koha 3. Notice the size of the backups: $ ls -lh /var/spool/koha/kohadev 4. Try the new option switch: $ debian/scripts/koha-run-backups \ --exclude-indexes \ --days 2 --output /var/spool/koha 5. Repeat 3 => SUCCESS: Backups are smaller! 6. Sign off :-D Signed-off-by: David Nind Signed-off-by: Nick Clemens JD amended patch: fix --exclude_indexes vs --exclude-indexes in koha-run-backups.xml --- debian/docs/koha-run-backups.xml | 7 +++++++ debian/scripts/koha-run-backups | 17 +++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/debian/docs/koha-run-backups.xml b/debian/docs/koha-run-backups.xml index 653a611a4f..3684421035 100644 --- a/debian/docs/koha-run-backups.xml +++ b/debian/docs/koha-run-backups.xml @@ -46,6 +46,13 @@ + + + + Exclude Zebra indexes from the backups (default: false). + + + diff --git a/debian/scripts/koha-run-backups b/debian/scripts/koha-run-backups index 74f879b744..1433c06ba1 100755 --- a/debian/scripts/koha-run-backups +++ b/debian/scripts/koha-run-backups @@ -28,16 +28,19 @@ This allows automation of backing up the koha data and configuration to the filesystem. It will keep the past so many backups, discarding older ones. Options: - --output: the directory that the resulting files will be placed into. - (default: /var/spool/koha) - --days: the number of days to keep backups around for - (default: 2) + --output /path The directory that the resulting files will be placed into. + (default: /var/spool/koha) + --days 2 The number of days to keep backups around for + (default: 2) + --exclude-indexes Exclude Zebra indexes from the backups (default: false) Note: backups produced using this tool can be restored using \`koha-restore'. EOH } -CMD_LINE=`getopt -o h --long days:,output:,help -n 'koha-run-backups' -- "$@"` +exclude_indexes="" + +CMD_LINE=`getopt -o h --long days:,output:,help,exclude-indexes -n 'koha-run-backups' -- "$@"` if [ $? != 0 ] ; then show_help ; exit 1 ; fi @@ -50,6 +53,8 @@ while true ; do days=$2; shift 2 ;; --output) dirname=$2; shift 2 ;; + --exclude-indexes) + exclude_indexes='--exclude-indexes'; shift ;; --) shift ; break ;; *) echo "Unknown error parsing the command line!" ; exit 1 ;; esac @@ -57,7 +62,7 @@ done for name in $(koha-list --enabled | grep -Fxv demo) do - koha-dump "$name" > /dev/null + koha-dump ${exclude_indexes} "$name" > /dev/null if [ -z "$dirname" ]; then backupdir="$( xmlstarlet sel -t -v 'yazgfs/config/backupdir' /etc/koha/sites/$name/koha-conf.xml )"; else -- 2.20.1