Koha Backup and Restoration Guide for Beginners

A Koha backup is not just a technical task. It protects your library’s catalog, patron records, circulation history, reports, notices, item data, and system settings. If your Koha server fails, a good backup can save days or even weeks of work.

This Koha backup and restoration guide explains the safest beginner-friendly methods for backing up and restoring Koha. It covers official Koha package tools such as koha-dumpkoha-run-backups, and koha-restore, plus the manual MySQL or MariaDB method using mysqldump.

The guide is written for beginners who manage Koha on a Linux server, especially Debian or Ubuntu package-based installations. You will learn what to back up, how to restore your system, how to rebuild search indexes, and how to test Koha after recovery.

Why Koha Backups Matter for Every Library

Koha stores important library data in a database. That data may include bibliographic records, item barcodes, patrons, checkouts, holds, fines, reports, notices, system preferences, and staff permissions. Losing this data can stop circulation, damage patron trust, and make catalog recovery very difficult.

A backup is your recovery plan. It protects the library when a server crashes, a database import fails, an upgrade breaks, a staff member deletes data by mistake, or a migration goes wrong. For a small school library, this may mean saving a few thousand records. For a college or public library, it may mean protecting years of circulation history.

A good backup plan should answer three simple questions: what is backed up, where it is stored, and whether it can be restored successfully.

What Data Should a Complete Koha Backup Include?

A complete Koha backup should include more than the database. Many beginner tutorials only show how to export the MySQL database, but Koha also depends on configuration files, uploaded files, search indexes, web server settings, and scheduled jobs.

Koha DataWhy It MattersBackup Priority
Koha databaseStores bibliographic records, patrons, checkouts, holds, reports, notices, and settingsVery High
Koha configuration filesStores instance settings, database credentials, ports, and pathsVery High
Uploaded filesNeeded if your Koha uses file uploads or attached documentsHigh
OPAC customizationsIncludes custom CSS, JavaScript, logos, and design settingsHigh
Zebra indexesHelps Koha search work quickly after restoreMedium
Cron job settingsRuns notices, indexing, cleanup, fines, and other background tasksHigh
Apache or web server configHelps restore URLs, ports, and site accessMedium
Backup logsHelps confirm whether backups completed successfullyMedium

Koha Backup Methods Compared

Beginners often ask which backup method is best. The answer depends on your installation type and goal. For modern Koha package installations, koha-dump is usually the best starting point because it is built for Koha.

MethodBest ForWhat It Backs UpBeginner Rating
koha-dumpFull backup of one Koha instanceDatabase, configs, and optional uploaded files/indexesBest default option
koha-run-backupsAutomated scheduled backupsKoha instance backups with retention settingsBest for production
mysqldumpDatabase-only backup or manual migrationKoha database onlyUseful but incomplete
MARC exportExporting catalog records onlyBibliographic, item, or authority recordsNot a full backup

Before You Start: Beginner Safety Checklist

Before running backup or restore commands, collect the basic details of your Koha system. This avoids common mistakes and makes recovery safer.

ItemExample
Koha instance namelibrary
Koha database namekoha_library
Koha version24.1125.0525.11
Server OSUbuntu or Debian
Backup location/backups/koha/
Free disk spaceMore than the database and upload size
Root or sudo accessRequired for most commands
Off-server storageAnother server, external drive, or secure cloud
Test restore planA separate test server or virtual machine

Do not restore a live Koha database without a fresh backup. Restoration can overwrite existing data, so always work carefully.

How to Find Your Koha Instance Name

The Koha instance name is not always the same as the database name. This is one of the most common beginner mistakes.

Run this command:

sudo koha-list --enabled

If the output is:

library

Then your Koha instance name is:

library

Your database name is usually:

koha_library

Use the instance name with Koha commands such as koha-dumpkoha-upgrade-schema, and koha-rebuild-zebra. Use the database name with MySQL or MariaDB commands.

Method 1: Full Koha Backup Using koha-dump

For a package-based Koha installation, the easiest full backup command is:

sudo koha-dump library

This creates a backup of the Koha instance. A typical backup includes a compressed SQL database dump and a compressed configuration dump.

You may find the backup files under a Koha spool or backup directory such as:

/var/spool/koha/library/

Check the files:

ls -lh /var/spool/koha/library/

You may see files similar to:

library-2026-05-17.sql.gz
library-2026-05-17.tar.gz

The .sql.gz file contains the database dump. The .tar.gz file contains Koha configuration and site-related files.

Include Uploaded Files in the Backup

If your library uses Koha uploaded files, include them:

sudo koha-dump --uploaded_files library

If temporary uploaded files also matter, use:

sudo koha-dump --uploaded_files --uploaded_temp_files library

Exclude Zebra Indexes to Reduce Backup Size

Zebra indexes can make backups larger. If you want a smaller backup and you are ready to rebuild the index after restore, use:

sudo koha-dump --exclude-indexes library

This keeps the backup lighter, but you must rebuild Zebra after restoring Koha.

Method 2: Automated Koha Backups Using koha-run-backups

A one-time backup is not enough for a live library. You need regular backups. Koha includes koha-run-backups, which can create scheduled backups and keep them for a selected number of days.

Example command:

sudo koha-run-backups --output /backups/koha --days 7

This stores backups in:

/backups/koha

And keeps backups for 7 days.

If you want smaller backups, you can exclude indexes:

sudo koha-run-backups --output /backups/koha --days 7 --exclude-indexes

For a beginner-friendly production setup, keep at least 7 daily backups and one weekly off-server backup. If your library has heavy circulation, consider longer retention.

Method 3: Manual Koha Database Backup Using mysqldump

Manual database backup is useful when you only need the database or when you are following an older migration tutorial. However, remember that mysqldump backs up the database only. It does not automatically back up Koha configuration files, uploaded files, Apache settings, or custom server files.

Basic backup:

sudo mysqldump -u root -p koha_library > koha_library.sql

Compressed backup:

sudo mysqldump -u root -p koha_library | gzip > koha_library.sql.gz

Safer backup for InnoDB tables:

sudo mysqldump -u root -p \
  --single-transaction \
  --routines \
  --triggers \
  --events \
  koha_library | gzip > koha_library_$(date +%F).sql.gz

This is helpful for database-only backup, but it should not replace a full Koha backup plan.

How to Restore Koha Using koha-restore

Use koha-restore when your backup was created with koha-dump.

The restore command needs two files:

library-2026-05-17.sql.gz
library-2026-05-17.tar.gz

Run:

sudo koha-restore library-2026-05-17.sql.gz library-2026-05-17.tar.gz

Use this method on a clean or prepared server. The restore process may stop if existing files conflict with the backup files. This protects the current server from accidental overwriting.

How to Restore a Manual SQL Backup to a New Koha Server

Use this method when you only have a .sql or .sql.gz database backup.

Step 1: Stop Services

sudo systemctl stop apache2
sudo systemctl stop memcached

If your Koha uses Plack, run:

sudo koha-plack --stop library

Step 2: Open MySQL or MariaDB

sudo mysql -u root -p

Step 3: Drop and Recreate the Database

Be careful. This removes the current database.

DROP DATABASE koha_library;
CREATE DATABASE koha_library CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
EXIT;

Step 4: Import the Backup

For an uncompressed SQL file:

sudo mysql -u root -p koha_library < koha_library.sql

For a compressed file:

gunzip -c koha_library.sql.gz | sudo mysql -u root -p koha_library

Why Schema Upgrade Is Important After Restore

When you restore an older Koha database into a newer Koha installation, the database structure may not match the new Koha code. That is why you must run:

sudo koha-upgrade-schema library

This command upgrades the Koha database schema for the instance. Think of schema upgrade like adjusting the shelves before placing the books back. Your data may be there, but the newer Koha version needs the database structure to match its current rules.

Why Zebra Rebuild Is Important After Restore

After restoring Koha, your records may exist in the database but not appear correctly in search. This usually happens because the Zebra search index needs to be rebuilt.

Run:

sudo koha-rebuild-zebra -v -f library

If your search is broken after restore, do not panic. First confirm the database imported correctly, then rebuild Zebra, restart services, and test OPAC search again.

Restart Services After Restore

After schema upgrade and Zebra rebuild, restart the main services:

sudo systemctl restart memcached
sudo systemctl restart apache2

If using Plack:

sudo koha-plack --restart library

If needed, restart Zebra:

sudo koha-zebra --restart library

Now open the staff interface and OPAC in your browser.

Post-Restore Testing Checklist

Do not stop after the command line says the restore is complete. Test the system like a staff member and a patron.

Area to TestWhat to Check
Staff loginStaff account opens correctly
OPACPublic catalog loads without errors
SearchTitle, author, subject, barcode, and advanced search work
Bibliographic recordsMARC records, items, call numbers, and barcodes appear
Patron recordsPatron names, categories, permissions, and contact details appear
CirculationCheckouts, check-ins, renewals, and holds work
ReportsSaved SQL reports are still available
NoticesEmail templates and notices are present
System preferencesOPAC, circulation, cataloging, and staff settings are retained
Uploaded filesAttached files or uploaded documents open correctly
Cron jobsIndexing, overdue notices, cleanup, and fines jobs are active
OPAC designLogo, CSS, JavaScript, and theme settings look correct

Common Koha Backup and Restore Errors

Wrong Instance Name

This happens when a user runs the schema upgrade command with the database name instead of the Koha instance name.

Incorrect:

sudo koha-upgrade-schema koha_library

Correct:

sudo koha-upgrade-schema library

Search Does Not Work After Restore

The database may be restored correctly, but Zebra indexes may be missing or outdated. Run:

sudo koha-rebuild-zebra -v -f library

Backup File Is Too Large

Large Zebra indexes, logs, and old session data can increase backup size. If you need a smaller backup, exclude indexes and rebuild them after restoration.

sudo koha-dump --exclude-indexes library

Uploaded Files Are Missing

If you used only mysqldump, uploaded files were not included. Use a Koha backup command with uploaded files included:

sudo koha-dump --uploaded_files library

Restore Fails Because Files Already Exist

koha-restore may stop if files from the configuration dump already exist on the server. This helps avoid accidental overwriting. Use a clean server or remove conflicting files only after confirming they are safe to replace.

Simple Backup Schedule for Small Libraries

A small library does not need a complex enterprise backup system, but it does need consistency. A backup that never gets tested is only a hope. A tested restore is a real recovery plan.

Backup TaskRecommended Frequency
Database backupDaily
Full Koha backup with configDaily or weekly
Off-server copyDaily or weekly
Test restoreMonthly
Pre-upgrade backupBefore every Koha upgrade
Backup log reviewWeekly

Beginner Example: Moving Koha From an Old Server to a New Server

Imagine your old server has a Koha instance called library, and you want to move it to a new server.

On the old server, create a full backup:

sudo koha-dump --uploaded_files library

Copy the backup files to the new server:

scp /var/spool/koha/library/library-2026-05-17.* user@newserver:/backups/

On the new server, restore using:

cd /backups
sudo koha-restore library-2026-05-17.sql.gz library-2026-05-17.tar.gz

Then run:

sudo koha-upgrade-schema library
sudo koha-rebuild-zebra -v -f library
sudo systemctl restart memcached
sudo systemctl restart apache2

Finally, test the staff interface, OPAC, search, patrons, circulation, reports, notices, and uploaded files.

Security Tips for Koha Backup Files

Koha backups can contain sensitive patron information, contact details, borrowing history, staff accounts, and internal reports. Treat backup files like confidential library records.

Store backups in a protected directory:

sudo chmod 700 /backups/koha

Restrict backup file access:

sudo chmod 600 /backups/koha/*.gz

Use encrypted off-server storage when possible. Do not leave Koha backups in a public web directory. Do not send unencrypted backup files through email or public file-sharing links.

Quick Command Summary

TaskCommand
List Koha instancessudo koha-list --enabled
Full Koha backupsudo koha-dump library
Backup with uploaded filessudo koha-dump --uploaded_files library
Backup without Zebra indexessudo koha-dump --exclude-indexes library
Automated backupsudo koha-run-backups --output /backups/koha --days 7
Manual database backupsudo mysqldump -u root -p koha_library > koha_library.sql
Restore Koha dumpsudo koha-restore file.sql.gz file.tar.gz
Restore manual SQLsudo mysql -u root -p koha_library < koha_library.sql
Upgrade schemasudo koha-upgrade-schema library
Rebuild Zebrasudo koha-rebuild-zebra -v -f library
Restart servicessudo systemctl restart memcached apache2

FAQs About Koha Backup and Restoration

What is the best way to back up Koha?

For package-based Koha installations, the best beginner-friendly method is usually koha-dump because it is designed for Koha instances and can include configuration files, uploaded files, and optional Zebra indexes. Use koha-run-backups when you want automated backups with retention settings.

Is mysqldump enough for Koha?

mysqldump is enough for a database-only backup, but it is not enough for a complete Koha backup. It does not automatically include Koha configuration files, uploaded files, OPAC customizations, or server settings.

What is the difference between koha-dump and mysqldump?

koha-dump is a Koha-specific backup tool. It can back up the Koha site contents and configuration. mysqldump is a MySQL or MariaDB database backup tool. It only backs up the database you select.

Do I need to rebuild Zebra after restoring Koha?

Yes, in most manual restore or migration cases, you should rebuild Zebra. If you skip this step, records may exist in the database but fail to appear in OPAC or staff search.

What is koha-upgrade-schema?

koha-upgrade-schema updates the database structure so it matches the installed Koha version. It is especially important when restoring an older Koha database into a newer Koha installation.

Where are Koha backups stored?

The exact location depends on your command and configuration. Many Koha package backups are placed under /var/spool/koha/, while koha-run-backups --output /backups/koha stores them in the output directory you choose.

Can I restore an old Koha database to a newer version?

Yes, but you must be careful. After importing the old database, run koha-upgrade-schema, rebuild Zebra, restart services, and test all important library workflows. Very old Koha versions may need a staged migration or MARC/CSV export approach.

Should I include Zebra indexes in my backup?

Include Zebra indexes if you want faster recovery and have enough storage. Exclude them if you want smaller backups and are comfortable rebuilding the index after restore.

How often should a library back up Koha?

A live library should usually back up Koha daily. Small libraries can keep 7 to 30 days of backups. Larger libraries should use longer retention, off-server storage, and regular restore testing.

Can I export MARC records instead of a full Koha backup?

MARC export is useful for catalog preservation, sharing records, or emergency bibliographic recovery. However, it is not a full Koha backup because it does not include patrons, circulation history, system preferences, reports, or staff settings.

Final Thoughts

A good Koha backup and restoration guide should teach more than one command. Beginners need to understand what Koha stores, which backup method fits their situation, how to restore safely, and how to test the system after recovery.

For most modern Koha servers, start with koha-dump for full backups, use koha-run-backups for automation, keep off-server copies, and test your restore process regularly. Use mysqldump when you need a database-only backup, but do not treat it as a full Koha disaster recovery plan.

Faheem Akbar
Faheem Akbar

Faheem Akbar is a Pakistani educator, researcher, blogger, and digital content creator known for publishing educational and professional development content through VWS Online. His work focuses on education, online learning, technology, academic research, career development, vocational skills, and digital awareness.

He is recognized for creating practical, research-based articles designed to help students, professionals, researchers, and lifelong learners improve their knowledge and professional growth. Through his platform, he shares insights on academic guidance, emerging technologies, online opportunities, and skill development.

Faheem Akbar maintains a professional presence on LinkedIn and Facebook, where he engages with audiences interested in education, research, and digital learning.

Articles: 48

Leave a Reply

Your email address will not be published. Required fields are marked *