Backing up Koha

From Koha Wiki

(Redirected from Mysqldump Library)
Jump to: navigation, search
Home > Documentation
Home > Documentation > Tips & Tricks
Obsolete
Note.jpg

WARNING! This page is obsolete.
This page is no longer correct and exists for historical reasons only.


mysqldump is a command line utility that can be used to dump data in the Koha database to a text file.

The examples assume a Koha database called koha and a Koha database user called kohaadmin.

Contents

Complete dump

To get all the data, use:

mysqldump -u kohaadmin -p koha > mydatadump.sql

  • -u specifies the user to log in to MySQL as, in this case kohaadmin
  • -p makes mysqldump prompt for the password
  • koha is the name of the database

There are certain tables in the Koha database you may not want or need to dump, like sessions and zebraqueue. These can be excluded with the --ignore-table option. Note that the option must be repeated for each table, and the table name must be given as databasename.tablename:

mysqldump -u kohaadmin -p --ignore-table koha.sessions --ignore-table koha.zebraqueue koha > mydatadump.sql

Note: If you choose to not dump the sessions table, be aware that loading the resulting dump into an empty db will probably result in errors like this:

Can't call method "delete" on an undefined value at /usr/share/koha/lib/C4/Auth.pm line 717.

To avoid this, restore the dump over a fresh db or omit '--ingnore-table koha.sessions'

Load data from mysqldump into a database

mysql -u kohaadmin -p koha < mydatadump.sql

A specific MARC framework

Assuming you have created a MARC framework called Yourcode you can dump all the relevant data into a file with this command:

mysqldump -u kohaadmin -p koha marc_subfield_structure marc_tag_structure biblio_framework --where "frameworkcode='Yourcode'" --no-create-info > myframework.sql

Installations running off the Debian packages

For installations that were created with the Debian packages, there are scripts for doing backup and restore, specifically:

  • koha-restore
  • koha-dump
  • koha-run-backups

See Commands provided by the Debian packages for details.

Links

Personal tools