0

Koha Database Backup

Share

We will set up an automated backup for Koha every day at 1:00 PM and 5:00 PM. The backup folder will retain the backups from the last 7 days

Create a Folder Under the root directory for backup

open a terminal and execute the bellow command

mkdir /backup

now create a backup script under the path /usr/local/bin

cd /usr/local/bin

sudo mousepad backup.sh

the above command will open a text editor in which copy paste the bellow content and change the “koha_library” marked in red Colour with your Mysql Username and “password” marked in red with your mysql password and “backup” marked in red with your backup folder name and save the file

#!/bin/bash

mysqldump -ukoha_library -ppassword koha_library | gzip > /backup/koha_library-$(date +%d-%m-%Y-%H.%M).sql.gz


find /backup/* -mtime +7 -exec rm {} \;

Now Provide necessary Permission to the backup script

sudo chmod +x backup.sh

Now we are going to create Cronejob entry for executing the script automatically every day at 01.00pm and 05.00 pm

execute the bellow commands on terminal

crontab -e

Copy the below lines to the bottom part of the crontab file.

#Koha Backup - 01.00PM
00 13 * * * /usr/local/bin/backup.sh
#Koha Backup - 05.00PM
00 17 * * * /usr/local/bin/backup.sh

Restart Crontab Service

sudo systemctl restart cron