18/03/2019

Koha Backup | How to Setup Automatic Backup in Koha 21.05

By Technical Digit

Create Shell Script for Daily Koha Backup

To setup Automatic Daily Koha Backup, Follow the below Commands.

First of all, Login to root user and create directory for backup.

sudo su
Enter Login password when prompted.

Next, Create Koha Backup directory

mkdir koha_backup

Allow write permission to this folder

sudo chmod 777 koha_backup

(Now, Exit from root directory)

Create a backup file.

sudo gedit koha_backup/backup.sh

Copy below text into file and save it.

#!/bin/bash
mysqldump -u[username] -p[password] koha_library | xz > koha_backup/koha_library-$(date +%d-%m-%Y-%H.%M).sql.xz

(Change [username] & [password] as per your Koha Database Credentials)

 Make this file executable by running following command

sudo chmod +x koha_backup/backup.sh

Execute the file to take backup.

sh koha_backup/backup.sh

Next, Schedule Koha backup using cron job, Open Crontab using nano editor.

crontab -e

It will ask to select an editor to open crontab, select nano editor.

Add following lines at the end.

45 15 * * * koha_backup/backup.sh
00 16 * * * find koha_backup/* -mtime +180 -exec rm {} \;

Save it by using Ctrl+o and ENTER, then press Ctrl+x to exit the cron.

Koha Backup

It will automatically take Backup at 03:45 PM daily. It will also delete backup files older than 180 days.

Also Read: Automatic Daily Backup of Dspace Software

 

Total Views: 2142