Bugzilla – Attachment 44442 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 --exclude-indexes switch to koha-dump
Bug-14532-Add---exclude-indexes-switch-to-koha-dum.patch (text/plain), 7.56 KB, created by
Tomás Cohen Arazi (tcohen)
on 2015-11-04 23:18:23 UTC
(
hide
)
Description:
Bug 14532: Add --exclude-indexes switch to koha-dump
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2015-11-04 23:18:23 UTC
Size:
7.56 KB
patch
obsolete
>From 0e3fc5a979f246e83b174d17dd5d918ab8c79efd 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 --exclude-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 your_instance >=> SUCCESS: Verify the contents of the dump are the same > (i.e. it includes /var/lib/koha/your_instance) >- Run with the new switch: > $ koha-dump --exclude-indexes 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..5224fe7 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>--exclude-indexes</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>--exclude-indexes</option></term> >+ <listitem> >+ <para>Make <command>koha-dump</command> exclude Zebra indexes during the dump operation. Having the Zebra indexes on the dump is useful for fast recovering Koha instances using <command>koha-restore</command> but the dumps tend to be a lot bigger and slower to create. Use this option to skip it.</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..9961093 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 >+ >+ --exclude-indexes 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 [ "$exclude_indexes" = "no" ] >+ 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" >+exclude_indexes="no" >+ >+while [ $# -gt 0 ]; do >+ >+ case "$1" in >+ --exclude-indexes) >+ exclude_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.6.2
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