There have been multiple instances where library professionals tend to lose months or years of their work just due to the negligence of IT professionals. I myself have communicated to many of such professionals whee their entire library database was lost, in which they have placed more than 2000 man-hours, just due to sheer negligence or professional callousness. In this article, I will explain how to take automatic backup of your Koha Mysql database in a SQL file.

To remedy the problem I thought why not help these professionals so that they can maintain their own server and be independent. For this reason, I am writing this blog to help library professionals.

In this blog, I have listed down some of the steps those library professionals can use to safeguard and maintain their own work without any help. There are three things that have to be done:-

  • Prepare your own koha server.
  • Automatically take backup of your entire installation.
  • Maintain your server on your own.

To do these in a very easy way I have prepared the ingredients on my own so that technical details can be abstracted. For this download the following from the prerequisites section:


  1. For installation follow the instructions given on this page
  2. Open Terminal by pressing Ctrl + Alt + T.
  3. After installation is over then create a new file. Type the following command in terminal:  $ nano
  4. Copy the script given below and paste it into a file. Save the script using Ctrl W and exit using Ctrl X.
  5. Type crontab -e on terminal. 
  6. Type the following code inside the file.

    0 8,23 * * * sh $HOME/ >> $HOME/bk.log 2>&1

    Save the script using Ctrl W and exit Ctrl X. 
  7. Now your backup will be done two times daily. First at 08:00 AM and 11:00 PM. 
#DATE="`date +%m`_`date +%d`_`date +%y`_`date +%H_%M_%S`.sql"
DATE="Koha_$(date +%b)_$(date +%d)_$(date +%Y)_$(date +%H_%M_%S).sql"
echo "Backing up the database with file name : " $DATE
cd $HOME
echo 'Changed  drive to' $PWD
echo 'Backing up the database'
mysqldump --user=root --password=Type your mysql password here --default-character-set=utf8 --single-transaction --all-databases  >  $DATE
echo 'Database backed successfully'
echo 'Database Uploading completed'
exit 0
Creative Commons License

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.