From fa431a1bcd5f2791393410eda2811e9b809f4ada Mon Sep 17 00:00:00 2001 From: Reed Wade Date: Fri, 27 Jun 2014 02:28:08 -0400 Subject: [PATCH] Bug 10532: koha-run-backups option --output doesn't work koha-dump has been modified to accept an optional --output option which is where it will create backup files. koha-run-dumps has been modified to always use that option when calling koha-dump --- debian/docs/koha-dump.xml | 4 +++- debian/scripts/koha-dump | 38 +++++++++++++++++++++++++++++++++++--- debian/scripts/koha-run-backups | 2 +- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/debian/docs/koha-dump.xml b/debian/docs/koha-dump.xml index a749fb2..70f0982 100644 --- a/debian/docs/koha-dump.xml +++ b/debian/docs/koha-dump.xml @@ -23,7 +23,9 @@ - koha-dump instancename + koha-dump + directory + instancename diff --git a/debian/scripts/koha-dump b/debian/scripts/koha-dump index bf4bd5f..d463462 100755 --- a/debian/scripts/koha-dump +++ b/debian/scripts/koha-dump @@ -27,24 +27,56 @@ else exit 1 fi +show_help() { + cat </koha-conf.xml) +EOH + +} + # Make sure the files we create are not accessible by anyone else. umask 0077 # Parse command line. -[ "$#" = 1 ] || die "Usage: $0 instancename" + +backupdir="" + +CMD_LINE=`getopt -o h --long output:,help -n 'koha-dump' -- "$@"` + +if [ $? != 0 ] ; then show_help ; exit 1 ; fi + +eval set -- "$CMD_LINE" +while true ; do + case "$1" in + -h|--help) + show_help; exit;; + --output) + backupdir=$2; shift 2 ;; + --) shift ; break ;; + *) echo "Unknown error parsing the command line!" ; exit 1 ;; + esac +done + +[ "$#" = 1 ] || die "Usage: $0 [ --output directory ] instancename" + name="$1" + + kohaconfig="/etc/koha/sites/$name/koha-conf.xml" date="$(date +%Y-%m-%d)" echo "Dumping Koha site $name:" - # Dump database. mysqlhost="$( xmlstarlet sel -t -v 'yazgfs/config/hostname' $kohaconfig )" mysqldb="$( xmlstarlet sel -t -v 'yazgfs/config/database' $kohaconfig )" mysqluser="$( xmlstarlet sel -t -v 'yazgfs/config/user' $kohaconfig )" mysqlpass="$( xmlstarlet sel -t -v 'yazgfs/config/pass' $kohaconfig )" -backupdir="$( xmlstarlet sel -t -v 'yazgfs/config/backupdir' $kohaconfig || true )" +[ -z "$backupdir" ] && backupdir="$( xmlstarlet sel -t -v 'yazgfs/config/backupdir' $kohaconfig || true )" [ -z "$backupdir" ] && backupdir="/var/spool/koha/$name" dbdump="$backupdir/$name-$date.sql.gz" echo "* DB to $dbdump" diff --git a/debian/scripts/koha-run-backups b/debian/scripts/koha-run-backups index 74f879b..164e485 100755 --- a/debian/scripts/koha-run-backups +++ b/debian/scripts/koha-run-backups @@ -57,12 +57,12 @@ done for name in $(koha-list --enabled | grep -Fxv demo) do - koha-dump "$name" > /dev/null if [ -z "$dirname" ]; then backupdir="$( xmlstarlet sel -t -v 'yazgfs/config/backupdir' /etc/koha/sites/$name/koha-conf.xml )"; else backupdir="$dirname/$name"; fi + koha-dump --output "$backupdir" "$name" > /dev/null # Remove old dump files. # FIXME: This could probably be replaced by one line of perl. -- 1.9.1