How to schedule database backup in Koha

You can enable schedule backup of koha database with the help of cron job feature in Ubuntu. Cron is a system daemon used to execute desired tasks (in the background) at designated times.You can read more about cron in Ubuntu here.

In this process we put a mysql command to take backup of Koha database in every 60 minutes.

Create a folder in home folder called "backup", where backup file store.

Open Applications > Accessories > Terminal

 Apply the following command,

crontab -e

It will ask to select a text editor. You can select Nano text editor.

You can see crontab file content. Use down arrow button and move the cursor to bottom part of the cron file. Copy following command there.

*/60 * * * * mysqldump -ukoha_library -pkoha123 koha_library | xz > /home/koha/backup/koha_library.sql.xz

Run backup command in a specific time

15 16 * * * mysqldump -ukoha_library -pkoha123 koha_library | xz > /home/koha/backup/koha_library.sql.xz

Above mentioned command take a backup at 3:15 PM every day.

Apply  Ctrl + o button to save the file.

Then apply Ctrl + x to leave the cron.

You can find backup file in /home/koha/backup folder after 60 minutes.

Explanations of key parts in the command,

-u koha_library = MySQL Koha Database username

-p koha123 = password of Koha Database

koha_library = Koha database name

XZ = compression format.


  1. -u root = MySQL root user name

    -p mysqlroot = password of MySQL root user.

    koha_library = Koha database name

    what is purpose of above commands sir ? please explain .. thanks in advance!

  2. Sir Libsys backup how to import in koha

    1. Libsys previous version has marc export facility.

  3. Dear Vimal,

    I have a same query: How to use the backup of LibSys in Koha?

  4. How to take backup for specific branch library(ies) in Koha?