Bugzilla – Attachment 55379 Details for
Bug 12374
Add option to use mysqldump parameters with koha-dump
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12374: Add koha-mqsqldump script, analagous to koha-mysql
Bug-12374-Add-koha-mqsqldump-script-analagous-to-k.patch (text/plain), 8.03 KB, created by
Magnus Enger
on 2016-09-08 20:12:06 UTC
(
hide
)
Description:
Bug 12374: Add koha-mqsqldump script, analagous to koha-mysql
Filename:
MIME Type:
Creator:
Magnus Enger
Created:
2016-09-08 20:12:06 UTC
Size:
8.03 KB
patch
obsolete
>From c72cb61445e7d7a573e37edf21e4b46530e1c584 Mon Sep 17 00:00:00 2001 >From: Barton Chittenden <barton@bywatersolutions.com> >Date: Sat, 27 Aug 2016 17:33:06 +0000 >Subject: [PATCH] Bug 12374: Add koha-mqsqldump script, analagous to koha-mysql > >Includes documentation, koha-common.install entry, and bash completion. > >Signed-off-by: Magnus Enger <magnus@libriotech.no> >- Applied the patch >- Copied the resulting koha-mysqldump to a live system >- Created dumps with mysqldump and koha-mysqldump and diff'ed them >- Exported a single table with koha-mysqldump >- All looks well >- Running xt/verify-debian-docbook.xml revealed a stray XML element > in koha-common.xml, I'll do a followup for that > >I did not create a custom package and install that, so I have not >tested installation and tabcompletion. >--- > debian/docs/koha-common.xml | 8 +++++ > debian/docs/koha-mysql.xml | 1 + > debian/docs/koha-mysqldump.xml | 63 ++++++++++++++++++++++++++++++++++++++ > debian/koha-common.bash-completion | 3 +- > debian/koha-common.install | 1 + > debian/scripts/koha-mysqldump | 59 +++++++++++++++++++++++++++++++++++ > 6 files changed, 134 insertions(+), 1 deletion(-) > create mode 100644 debian/docs/koha-mysqldump.xml > create mode 100755 debian/scripts/koha-mysqldump > >diff --git a/debian/docs/koha-common.xml b/debian/docs/koha-common.xml >index 2790341..6969764 100644 >--- a/debian/docs/koha-common.xml >+++ b/debian/docs/koha-common.xml >@@ -113,6 +113,14 @@ > </listitem> > </varlistentry> > </variablelist> >+ >+ <varlistentry> >+ <term><option>koha-mysqldump</option></term> >+ <listitem> >+ <para>A wrapper for mysqldump for the specified koha instance.</para> >+ </listitem> >+ </varlistentry> >+ </variablelist> > </refsect2> > > <refsect2><title>Zebra-related</title> >diff --git a/debian/docs/koha-mysql.xml b/debian/docs/koha-mysql.xml >index f0360be..84657bc 100644 >--- a/debian/docs/koha-mysql.xml >+++ b/debian/docs/koha-mysql.xml >@@ -63,6 +63,7 @@ > <refsect1><title>See also</title> > <simplelist type="inline"> > <member><command>mysql (1)</command></member> >+ <member><command>koha-mysqlsump (1)</command></member> > <member><command>koha-dump-defaults(8)</command></member> > <member><command>koha-reset-passwd(8)</command></member> > <member><command>koha-upgrade-schema(8)</command></member> >diff --git a/debian/docs/koha-mysqldump.xml b/debian/docs/koha-mysqldump.xml >new file mode 100644 >index 0000000..e11fd89 >--- /dev/null >+++ b/debian/docs/koha-mysqldump.xml >@@ -0,0 +1,63 @@ >+<article xmlns='http://docbook.org/ns/docbook'> >+<title>koha-mysqldump</title> >+<info> >+<productname>Koha</productname> is the first free software library automation package. >+<author> >+ <orgname>The Koha Community</orgname> >+ <uri>http://koha-community.org/</uri> >+</author> >+</info> >+ >+<refentry xml:id="koha-mysqldump"> >+ >+ <refmeta> >+ <refentrytitle>koha-mysqldump</refentrytitle> >+ <manvolnum>8</manvolnum> >+ </refmeta> >+ >+ <refnamediv> >+ <refname>koha-mysqldump</refname> >+ <refpurpose>Provide a flexible database dumper for the specified koha instance.</refpurpose> >+ <refclass>UNIX/Linux</refclass> >+ </refnamediv> >+ >+ <refsynopsisdiv> >+ <cmdsynopsis> >+ <command>koha-mysqldump</command> <arg choice="req" rep="norepeat"><replaceable>instancename</replaceable></arg> <arg choice="opt" rep="repeat">mysqldump option</arg> >+ </cmdsynopsis> >+ </refsynopsisdiv> >+ >+ <refsect1><title>Description</title> >+ <para>A wrapper for mysqldump for the specified koha instance.</para> >+ </refsect1> >+ >+ <refsect1><title>Example usage</title> >+ <variablelist> >+ <varlistentry> >+ <term>Dump the database associated with a given instance. SQL output goes to STDOUT.</term> >+ <listitem> >+ <para><command>koha-mysqldump</command> <arg choice="req" rep="norepeat"><replaceable>instancename</replaceable></arg></para> >+ </listitem> >+ </varlistentry> >+ <varlistentry> >+ <term>Dump data from TABLENAME matching the where clause, redirect output to a file</term> >+ <listitem> >+ <para><command>koha-mysqldump</command> <arg choice="req" rep="norepeat"><replaceable>instancename</replaceable></arg> TABLENAME --where "SOME SQL QUERY" > TABLENAME.sql</para> >+ </listitem> >+ </varlistentry> >+ </variablelist> >+ </refsect1> >+ >+ <refsect1><title>See also</title> >+ <simplelist type="inline"> >+ <member><command>mysqldump (1)</command></member> >+ <member><command>koha-mysql (1)</command></member> >+ <member><command>koha-dump-defaults(8)</command></member> >+ <member><command>koha-reset-passwd(8)</command></member> >+ <member><command>koha-upgrade-schema(8)</command></member> >+ </simplelist> >+ </refsect1> >+ >+</refentry> >+ >+</article> >diff --git a/debian/koha-common.bash-completion b/debian/koha-common.bash-completion >index 637a56b..2e53791 100644 >--- a/debian/koha-common.bash-completion >+++ b/debian/koha-common.bash-completion >@@ -135,8 +135,9 @@ complete -F _koha_enabled_instances koha-start-zebra > complete -F _koha_enabled_instances koha-restart-zebra > complete -F _koha_enabled_instances koha-stop-zebra > >-# koha-mysql autocompletes with a single instance name >+# koha-mysql* autocompletes with a single instance name > complete -F _koha_single_instance koha-mysql >+complete -F _koha_single_instance koha-mysqldump > > _koha_list() > { >diff --git a/debian/koha-common.install b/debian/koha-common.install >index 270a54a..b4214bd 100644 >--- a/debian/koha-common.install >+++ b/debian/koha-common.install >@@ -20,6 +20,7 @@ debian/scripts/koha-foreach usr/sbin > debian/scripts/koha-indexer usr/sbin > debian/scripts/koha-list usr/sbin > debian/scripts/koha-mysql usr/sbin >+debian/scripts/koha-mysqldump usr/sbin > debian/scripts/koha-passwd usr/sbin > debian/scripts/koha-plack usr/sbin > debian/scripts/koha-rebuild-zebra usr/sbin >diff --git a/debian/scripts/koha-mysqldump b/debian/scripts/koha-mysqldump >new file mode 100755 >index 0000000..c2fed88 >--- /dev/null >+++ b/debian/scripts/koha-mysqldump >@@ -0,0 +1,59 @@ >+#!/bin/sh >+# >+# koha-mysqldump: run mysqldump on the database of the specified Koha instance. >+# Copyright 2016 Barton Chittenden >+# Based on koha-mysql, which is Copyright 2011 Catalyst IT, Ltd >+# >+# This program is free software: you can redistribute it and/or modify >+# it under the terms of the GNU General Public License as published by >+# the Free Software Foundation, either version 3 of the License, or >+# (at your option) any later version. >+# >+# This program is distributed in the hope that it will be useful, >+# but WITHOUT ANY WARRANTY; without even the implied warranty of >+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the >+# GNU General Public License for more details. >+# >+# You should have received a copy of the GNU General Public License >+# along with this program. If not, see <http://www.gnu.org/licenses/>. >+ >+set -e >+ >+umask 0077 >+ >+# include helper functions >+if [ -f "/usr/share/koha/bin/koha-functions.sh" ]; then >+ . "/usr/share/koha/bin/koha-functions.sh" >+else >+ echo "Error: /usr/share/koha/bin/koha-functions.sh not present." 1>&2 >+ exit 1 >+fi >+ >+usage() >+{ >+ local scriptname=$0 >+ cat <<EOF >+Run mysqldump in the context of a given Koha instance. >+ >+Usage: $scriptname instancename [ optional mysqldump arguments ] >+ >+EOF >+} >+ >+# Parse command line. >+[ $# -ge 1 ] || ( usage ; die "Missing instance name..." ) >+ >+name="$1" >+ >+is_instance "$name" || ( usage; die "Unknown instance '$name'" ) >+ >+shift # remove instance name from argument list. >+kohaconfig="/etc/koha/sites/$name/koha-conf.xml" >+ >+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 )" >+ >+mysqldump --host="$mysqlhost" --user="$mysqluser" --password="$mysqlpass" \ >+ "$mysqldb" "${@}" >-- >2.7.4
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 12374
:
54945
|
55342
| 55379 |
55380
|
55381