Bugzilla – Attachment 41098 Details for
Bug 14532
koha-dump should provide a way to exclude Zebra indexes
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14532: Add --include-indexes switch to koha-dump
Bug-14532-Add---include-indexes-switch-to-koha-dum.patch (text/plain), 7.61 KB, created by
Tomás Cohen Arazi (tcohen)
on 2015-07-20 15:24:12 UTC
(
hide
)
Description:
Bug 14532: Add --include-indexes switch to koha-dump
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2015-07-20 15:24:12 UTC
Size:
7.61 KB
patch
obsolete
>From d537e991cc75594ac9e678f484eb35bb1e6ec2aa Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Mon, 20 Jul 2015 12:18:03 -0300 >Subject: [PATCH] Bug 14532: Add --include-indexes switch to koha-dump > >This patch changes the default behaviour of koha-dump to make the inclusion >of Zebra indexes on the dump optional. It does so by introducing a new option >switch that allows to have the previous behaviour in place. > >To test: >- Run > $ koha-dump your_instance >- Save a copy of the dump files >- Apply the patch / extract the koha-dump script >- Run the new one: > $ koha-dump --include-indexes your_instance > (you can use -i too) >=> SUCCESS: Verify the contents of the dump are the same > (i.e. it includes /var/lib/koha/your_instance) >- Run > $ koha-dump your_instance >=> SUCCESS: The dump does not contain stuff from /var/lib/koha/your_instance >- Go through the rest of the new option switches > -h | --help > -q | --quiet >=> SUCCESS: They work as expected. >- Sign off :-D > >Regards >--- > debian/docs/koha-dump.xml | 38 +++++++++++- > debian/scripts/koha-dump | 153 +++++++++++++++++++++++++++++++++++----------- > 2 files changed, 152 insertions(+), 39 deletions(-) > >diff --git a/debian/docs/koha-dump.xml b/debian/docs/koha-dump.xml >index a749fb2..aa7c95d 100644 >--- a/debian/docs/koha-dump.xml >+++ b/debian/docs/koha-dump.xml >@@ -23,12 +23,46 @@ > > <refsynopsisdiv> > <cmdsynopsis> >- <command>koha-dump</command> <arg choice="req" rep="norepeat"><replaceable>instancename</replaceable></arg> >+ <command>koha-dump</command> >+ <arg choice="noreq"> >+ <option>--help</option>|<option>-h</option> >+ <option>--include-indexes</option>|<option>-i</option> >+ <option>--quiet</option>|<option>-q</option> >+ </arg> >+ <arg choice="req" rep="repeat"><replaceable>instancename</replaceable></arg> > </cmdsynopsis> > </refsynopsisdiv> > >+ <refsect1> >+ <title>Options</title> >+ <variablelist> >+ >+ <varlistentry> >+ <term><option>--include-indexes</option>|<option>-i</option></term> >+ <listitem> >+ <para>Make <command>koha-dump</command> include Zebra indexes during the dump operation. This is useful for fast recovering Koha instances using <command>koha-restore</command> (i.e. there's no need to reindex your database). The drawback is that dumps tend to be a lot bigger and slower to create.</para> >+ </listitem> >+ </varlistentry> >+ >+ <varlistentry> >+ <term><option>--quiet</option>|<option>-q</option></term> >+ <listitem> >+ <para>Make <command>koha-dump</command> run silently.</para> >+ </listitem> >+ </varlistentry> >+ >+ <varlistentry> >+ <term><option>--help</option>|<option>-h</option></term> >+ <listitem> >+ <para>Show usage information.</para> >+ </listitem> >+ </varlistentry> >+ >+ </variablelist> >+ </refsect1> >+ > <refsect1><title>Description</title> >- <para>Dump all contents and configs for a Koha site.</para> >+ <para>Dump all contents and configs for one or more Koha instances.</para> > </refsect1> > > <refsect1><title>See also</title> >diff --git a/debian/scripts/koha-dump b/debian/scripts/koha-dump >index bf4bd5f..a156d57 100755 >--- a/debian/scripts/koha-dump >+++ b/debian/scripts/koha-dump >@@ -30,40 +30,119 @@ fi > # Make sure the files we create are not accessible by anyone else. > umask 0077 > >-# Parse command line. >-[ "$#" = 1 ] || die "Usage: $0 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="/var/spool/koha/$name" >-dbdump="$backupdir/$name-$date.sql.gz" >-echo "* DB to $dbdump" >-mysqldump --databases --host="$mysqlhost" \ >- --user="$mysqluser" --password="$mysqlpass" "$mysqldb" | >- gzip > "$dbdump" >-chown "root:$name-koha" "$dbdump" >-chmod g+r "$dbdump" >- >-instancefile="$name.conf" >- >-# Dump configs, logs, etc. >-metadump="$backupdir/$name-$date.tar.gz" >-echo "* configs, logs to $metadump" >-tar -C / -czf "$metadump" \ >- "etc/koha/sites/$name" \ >- "etc/apache2/sites-available/$instancefile" \ >- "etc/apache2/sites-enabled/$instancefile" \ >- "var/lib/koha/$name" \ >- "var/log/koha/$name" >- >-echo "Done." >+usage() >+{ >+ local scriptname=$(basename $0) >+ >+ cat <<EOF >+$scriptname >+ >+This script dumps your Koha instance data for backup or migration. >+ >+Usage: >+$scriptname [--quiet|-q] [--include-indexes|-i] instancename1 [instancename2...] >+$scriptname -h|--help >+ >+ --include-indexes|-i Include Zebra indexes on the backup. >+ --quiet|-q Make the script avoid printing to STDOUT >+ (useful for calling from another scripts). >+ --help|-h Display this help message >+ >+EOF >+} >+ >+dump_instance() >+{ >+ local name=$1 >+ >+ kohaconfig="/etc/koha/sites/$name/koha-conf.xml" >+ date="$(date +%Y-%m-%d)" >+ >+ [ "$quiet" = "no" ] && 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="/var/spool/koha/$name" >+ dbdump="$backupdir/$name-$date.sql.gz" >+ [ "$quiet" = "no" ] && echo "* DB to $dbdump" >+ mysqldump --databases --host="$mysqlhost" \ >+ --user="$mysqluser" --password="$mysqlpass" "$mysqldb" | >+ gzip > "$dbdump" >+ chown "root:$name-koha" "$dbdump" >+ chmod g+r "$dbdump" >+ >+ instancefile="$name.conf" >+ >+ # Dump configs, logs, etc. >+ metadump="$backupdir/$name-$date.tar.gz" >+ [ "$quiet" = "no" ] && echo "* configs, logs to $metadump" >+ >+ zebra_files="" >+ if [ "$include_indexes" = "yes" ] >+ zebra_files="var/lib/koha/$name" >+ fi >+ >+ tar -C / -czf "$metadump" \ >+ "etc/koha/sites/$name" \ >+ "etc/apache2/sites-available/$instancefile" \ >+ "etc/apache2/sites-enabled/$instancefile" \ >+ "var/log/koha/$name" "$zebra_files" >+ >+ [ "$quiet" = "no" ] && echo "Done." >+} >+ >+# Default values >+quiet="no" >+include_indexes="no" >+ >+while [ $# -gt 0 ]; do >+ >+ case "$1" in >+ -i|--include-indexes) >+ include_indexes="yes" >+ shift ;; >+ -h|--help) >+ usage ; exit 0 ;; >+ -q|--quiet) >+ quiet="yes" >+ shift ;; >+ -*) >+ die "Error: invalid option switch ($1)" ;; >+ *) >+ # We expect the remaining stuff are the instance names >+ break ;; >+ esac >+ >+done >+ >+# Read instance names >+if [ $# -gt 0 ]; then >+ # We have at least one instance name >+ for name in "$@"; do >+ >+ if is_instance $name; then >+ >+ dump_instance $name >+ >+ else >+ if [ "$quiet" = "no" ]; then >+ die "Error: Invalid instance name $name" >+ else >+ exit 1 >+ fi >+ fi >+ >+ done >+else >+ if [ "$quiet" = "no" ]; then >+ die "Error: you must provide at least one instance name" >+ else >+ exit 1 >+ fi >+fi >+ >+exit 0 >-- >2.4.6
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 14532
:
41098
|
44442
|
44674
|
44675
|
44676
|
47117
|
47307
|
47348
|
47349
|
47350
|
47351