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
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.
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
Â
Post navigation
One thought on “Koha Backup | How to Setup Automatic Backup in Koha 21.05”
Leave a Reply Cancel reply
You must be logged in to post a comment.
Hello
I am getting an error of access denied while trying to execute sh koha_backup/backup.sh