Bug 12374 - Add option to use mysqldump parameters with koha-dump
Summary: Add option to use mysqldump parameters with koha-dump
Status: NEW
Alias: None
Product: Koha
Classification: Unclassified
Component: Command-line Utilities (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Bugs List
QA Contact: Testopia
URL:
Keywords:
: 15874 (view as bug list)
Depends on:
Blocks:
 
Reported: 2014-06-05 15:43 UTC by Barton Chittenden
Modified: 2023-07-15 19:46 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Medium patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 12374: Add koha-mqsqldump script, analagous to koha-mysql (7.57 KB, patch)
2016-08-27 18:15 UTC, Barton Chittenden
Details | Diff | Splinter Review
Bug 12374: Add koha-mqsqldump script, analagous to koha-mysql (7.57 KB, patch)
2016-09-08 13:52 UTC, Barton Chittenden
Details | Diff | Splinter Review
Bug 12374: Add koha-mqsqldump script, analagous to koha-mysql (8.03 KB, patch)
2016-09-08 20:12 UTC, Magnus Enger
Details | Diff | Splinter Review
Bug 12374 - Followup to fix koha-common.xml (885 bytes, patch)
2016-09-08 20:14 UTC, Magnus Enger
Details | Diff | Splinter Review
Bug 12374 - Followup to fix koha-common.xml (955 bytes, patch)
2016-09-08 20:47 UTC, Barton Chittenden
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Barton Chittenden 2014-06-05 15:43:07 UTC
The command debian/scripts/koha-mysql is used to execute mysql on a given site without entering sql credentials, but if a database dump is required, there is not analogous tool available. It would be trivial to copy koha-mysql to koha-mysqldump and call mysqldump instead.

See notes in bug 12372 about passing arguments into such a script.
Comment 1 Magnus Enger 2014-06-23 21:28:54 UTC
We already have the koha-dump script, which creates two files, one mysqldump and one .tar.gz file containing some config and log files, in the /var/spool/koha/<instancename> dir. Perhaps it could be an option to extend this script with a couple more options, to make it possible to:

- not dump the configs and logs
- place the mysqldump in a given dir
Comment 2 Barton Chittenden 2016-08-27 18:15:25 UTC Comment hidden (obsolete)
Comment 3 Barton Chittenden 2016-08-27 18:22:58 UTC
(In reply to Magnus Enger from comment #1)
> We already have the koha-dump script, which creates two files, one mysqldump
> and one .tar.gz file containing some config and log files, in the
> /var/spool/koha/<instancename> dir. Perhaps it could be an option to extend
> this script with a couple more options, to make it possible to:
> 
> - not dump the configs and logs
> - place the mysqldump in a given dir

I feel that this tool fills a different need -- mysqldump has a *lot* of command line options not available in koha-dump -- chiefly, the ability to dump only a certain table, or perhaps only certain records in a given table.
Comment 4 Barton Chittenden 2016-08-27 18:44:09 UTC
Test plan:

1/ Run mysqldump by hand, redirect output to 'file1.sql'
   egrep '^..(user|database|pass|host)' $KOHA_CONF

   which will yield something like this:

    <database>koha_xyzzy</database>
    <hostname>localhost</hostname>
    <user>koha_xyzzy</user>
    <pass>setecAstronomy</pass>

   mysqldump -p -u koha_xyzzy -h localhost koha_xyzzy > file1.sql
   Enter password:

2/ Apply patch
3/ Run koha-mysqldump against the instance, redirect output to 'file2.sql'
   ./debian/scripts/koha-mysqldump xyzzy > file2.sql
4/ The files should be identical, except for time stamps contained in the file:

   diff file1.sql file2.sql
   5965c5965
   < -- Dump completed on 2016-08-27 11:33:42
   ---
   > -- Dump completed on 2016-08-27 11:35:48
Comment 5 Barton Chittenden 2016-09-08 13:52:53 UTC Comment hidden (obsolete)
Comment 6 Magnus Enger 2016-09-08 20:12:06 UTC
Created attachment 55379 [details] [review]
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.
Comment 7 Magnus Enger 2016-09-08 20:14:35 UTC Comment hidden (obsolete)
Comment 8 Magnus Enger 2016-09-08 20:16:13 UTC
I think my followup is simple enough that it does not need a signoff. Please reset status to "Needs signoff" if anyone disagrees.
Comment 9 Barton Chittenden 2016-09-08 20:47:48 UTC
Created attachment 55381 [details] [review]
Bug 12374 - Followup to fix koha-common.xml

The original patch left a stray <variablelist> element in
koha-common.xml. This patch removes it.

To test:
Run xt/verify-debian-docbook.t and see that it passes

Signed-off-by: Barton Chittenden <barton@bywatersolutions.com>
Comment 10 Liz Rea 2016-09-09 04:33:14 UTC
As noted in IRC, I don't like this solution for a number of reasons. 

We already have koha-dump, it's my feeling we should build in the option to use mysqldump parameters into that instead of having Yet Another Koha-* script to maintain and document.
Comment 11 Claudio Costales 2016-09-09 16:38:06 UTC
*** Bug 15874 has been marked as a duplicate of this bug. ***
Comment 12 Katrin Fischer 2016-09-10 18:41:22 UTC
I'd like to get some more opinions on this as both Magnus and Liz have left notes that this might be better as options for koha-mysql instead of having a completely separate new script.
Could you bring this up on the mailing list/meeting/IRC for some more comments, please?
Comment 13 Magnus Enger 2016-09-13 13:03:07 UTC
I changed my mind and vote in favour of koha-mysqldump.
Comment 14 Larry Baerveldt 2016-10-04 16:51:16 UTC
There is very much a need for this tool. We at ByWater have needed this for so long, that I wrote my own script very much like this.

To my mind, I have no problem with there being two scripts with overlapping functionality. They serve different purposes. 

Koha-dump is optimized for backups, plain and simple.

Koha-mysqldump has a different purpose, and is geared for those who need to have the option to use the full range of mysqldump options. The fact that both scripts happen to share a common underlying program should not be a strike against this one. 

As for the issue of maintaining another script, I think that's inconsequential. The script itself is dead simple, and once added, I think will not require much in the way of ongoing support. 

As for modifying the existing koha-dump script to allow mysqldump parameters, I think that's actually the more complicated solution. You would have to add an option to skip the configs backup, override the output directory and automatic gzipping of output, override the chown and chmod commands etc. Honestly, it would be easier to add this script and simply modify koha-dump to call *this* one for the mysql dump portion.

Also, if you were to modify koha-dump, it will probably require one or more command line option flags, to both override its normal function and to pass in the new options you might want to use. Koha-mysqldump is simpler, as after the initial command and site name, all remaining command line options are the same as for mysqldump. To reiterate my earlier comment about different functions, koha-dump's purpose is to do backups, koha-mysqldump's purpose is to simply put a wrapper around mysqldump. 

Yes, it would be possible to modify koha-dump to add this functionality, but my vote is for the new script. In my opinion, it's the simpler and easier way to add needed functionality, without making an existing script more complicated.

- Larry
Comment 15 Katrin Fischer 2023-07-15 19:46:48 UTC
(In reply to Liz Rea from comment #10)
> As noted in IRC, I don't like this solution for a number of reasons. 
> 
> We already have koha-dump, it's my feeling we should build in the option to
> use mysqldump parameters into that instead of having Yet Another Koha-*
> script to maintain and document.

I believe this is the correct solution.