Koha/koha-tmpl/intranet-tmpl/prog/en/modules/tools
Jared Camins-Esakov bbcb1d784b Bug 8268: Add database dump to export tool
This patch builds on work by Lars Wirzenius for the Koha packages.

To date, the only way for a Koha librarian to obtain a complete backup
of their system has been to log into the system via SSH (or FTP) to
download the mysqldump file. This patch makes it possible for
superlibrarians in properly configured systems to download night backups
via the staff client's Export tool.

Recognizing that this is functionality with potentially very grave
security implications, system administrators must manually enable these
features in the koha-conf.xml configuration file.

The following configuration settings have been added to the koha-conf.xml
file:
* backupdir => directory where backups should be stored.
* backup_db_via_tools => whether to allow superlibrarians to download
  database backups via the Export tool. The default is disabled, and
  there is no way -- by design -- to enable this option without manually
  editing koha-conf.xml.
* backup_conf_via_tools => whether to allow superlibrarians to download
  configuration backups via the Export tool (this may be applicable to
  packages only). The default is disabled, and there is no way -- by
  design -- to enable this option without manually editing koha-conf.xml.

This commit modifies the following scripts to make use of the new
backupdir configuration option:
* koha-dump and koha-run-backups in the Debian packages
* The sample backup script misc/cronjobs/backup.sh

Note that for security reasons, superlibrarians will not be allowed
to download files that are not owned by the web server's effective user.
This imposes a de facto dependency on ITK (for Apache) or running the
web server as the Koha user (as is done with Plack).

To test:
1. Apply patch.
2. Go to export page as a superlibrarian. Notice that no additional
   export options appear because they have not been enabled.
3. Add <backupdir>$KOHADEV/var/spool</backup> to the <config> section
   of your koha-conf.xml (note that you will need to adjust that so that
   it is pointing at a logical directory).
4. Create the aforementioned directory.
5. Go to export page as a superlibrarian. Notice that no additional
   export options appear because they have not been enabled.
6. Add <backup_db_via_tools>1</backup_db_via_tools> to the <config>
   section of your koha-conf.xml
7. Go to the export page as a superlibrarian. Notice the new tab.
8. Go to the export page as a non-superlibrarian. Notice there is no
   new tab.
9. Run: mysqldump -u koha -p koha | gzip > $BACKUPDIR/backup.sql.gz
   (substituting appropriate user, password, and database name)
10. Go to the export page as a superlibrarian, and look at the "Export
    database" tab. If you are running the web server as your Koha user,
    and ran the above command as your Koha user, you should now see the
    file listed as an option for download.
11. If you *did* see the file listed, change the ownership to something
    else: sudo chown root:root $BACKUPDIR/backup.sql.gz
11a. Confirm that you no longer see the file listed when you look at the
     "Export database" tab.
12. Change the ownership on the file to your web server (or Koha) user:
    sudo chown www-data:www-data backup.sql.gz
13. Go to the export page as a superlibrarian, and look at the "Export
    database" tab. You should now see backup.sql.gz listed.
14. Choose to download backup.sql.gz
15. Confirm that the downloaded file is what you were expecting.

If you are interested, you can repeat the above steps but replace
<backup_db_via_tools> with <backup_conf_via_tools>, and instead of
creating an sql file, create a tar file.

To test packaging: run koha-dump, confirm that it still creates a
usable backup.

------

This signoff contains two changes:

10-1. If no backup/conf files were present, then the message telling you
so doesn't appear and the download button does. Made them behave
correctly.
10-2. The test for a file existing required it to be owned by the
webserver UID. This change makes it so it only has to be readable.

Signed-off-by: Robin Sheat <robin@catalyst.net.nz>
2012-07-12 17:40:21 +02:00
..
batchMod-del.tt bug 6372: moved background-job.inc to background-job-progressbar.js 2012-05-07 23:00:34 +02:00
batchMod-edit.tt Bug 7739 - Batch edit items of a title 2012-05-11 12:16:22 +02:00
batchMod.tt Bug 7760 - Add ids and classes to every staff page to help with customization (tools) 2012-03-22 18:12:32 +01:00
cleanborrowers.tt Bug 8181 [REVISED] Replace DynArch calendar widget with jQueryUI version 2012-06-25 18:26:26 +02:00
csv-profiles.tt Bug 8143 [REVISED] Upgrade jQuery tabs to current jQueryUI version 2012-06-10 15:22:58 +02:00
export.tt Bug 8268: Add database dump to export tool 2012-07-12 17:40:21 +02:00
holidays.tt Bug 8181 [REVISED] Replace DynArch calendar widget with jQueryUI version 2012-06-25 18:26:26 +02:00
import_borrowers.tt [SIGNED-OFF]Bug 2780 - Capitalize strings consistently (tools) 2012-04-10 10:18:54 +02:00
inventory.tt Bug 8181 [REVISED] Replace DynArch calendar widget with jQueryUI version 2012-06-25 18:26:26 +02:00
koha-news.tt Bug 8181 [REVISED] Replace DynArch calendar widget with jQueryUI version 2012-06-25 18:26:26 +02:00
letter.tt Bug 7842 - Inconsistencies in Notices interface 2012-05-11 12:22:09 +02:00
manage-marc-import.tt bug 6372: moved background-job.inc to background-job-progressbar.js 2012-05-07 23:00:34 +02:00
modborrowers.tt Bug 8181 [REVISED] Replace DynArch calendar widget with jQueryUI version 2012-06-25 18:26:26 +02:00
overduerules.tt Bug 8143 [REVISED] Upgrade jQuery tabs to current jQueryUI version 2012-06-10 15:22:58 +02:00
picture-upload.tt [SIGNED-OFF]Bug 2780 - Capitalize strings consistently (tools) 2012-04-10 10:18:54 +02:00
quotes-upload.tt Bug 7977: Improving upload result message display 2012-05-24 14:15:09 +02:00
quotes.tt Bug 7977 follow-up, fixing UC breaking coding guidelines 2012-05-24 14:33:19 +02:00
scheduler.tt Bug 8181 [REVISED] Replace DynArch calendar widget with jQueryUI version 2012-06-25 18:26:26 +02:00
stage-marc-import.tt bug 6372: moved background-job.inc to background-job-progressbar.js 2012-05-07 23:00:34 +02:00
tools-home.tt Bug 8202: Add authority export to tools/export.pl 2012-07-04 16:21:06 +02:00
upload-images.tt bug 6372: moved background-job.inc to background-job-progressbar.js 2012-05-07 23:00:34 +02:00
viewlog.tt Bug 8181 [REVISED] Replace DynArch calendar widget with jQueryUI version 2012-06-25 18:26:26 +02:00