[Koha-patches] [PATCH] Bug 10532: koha-run-backups option --output doesn't work
Reed Wade
reed at typist.geek.nz
Fri Jun 27 08:34:02 CEST 2014
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 @@
<refsynopsisdiv>
<cmdsynopsis>
- <command>koha-dump</command> <arg choice="req" rep="norepeat"><replaceable>instancename</replaceable></arg>
+ <command>koha-dump</command>
+ <arg><option>--output</option> directory</arg>
+ <arg choice="req" rep="norepeat"><replaceable>instancename</replaceable></arg>
</cmdsynopsis>
</refsynopsisdiv>
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 <<EOH
+$0 - performs backup of a koha installations on the system
+
+Options:
+ --output: the directory that the backup files will be placed into.
+ (default: consults /etc/koha/sites/<instance>/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
More information about the Koha-patches
mailing list