Automatic updating of the Koha Offline Circulation borrowers file
Wouldn’t it be nice to know that your Koha Offline Circulation patron data was always up to date? It can be done! Here I will show you a very simple way to do this! This tutorial assumes you will be running the offline circulation client on a computer running a version of Microsoft Windows. Solutions for Linux and Mac OS X are just as possible, and actually easier, but will not be part of this tutorial.
This server side configurationis quite simple. The script to create the file is found at misc/cronjobs/create_koc_db.pl. To generate this file, we must simply add a line to the koha user’s crontab like this:
0 20 * * * /usr/share/koha/bin/cronjobs/create_koc_db.pl --file /tmp/borrowers.db --force --sqlite3
This crontab line will regenerate a fresh Koha borrowers.db file each day at 8:00 pm. This can be modified to run at a different time, or even multiple times per day. The actual path to your create_koc_db.pl script will vary depending on the type of installation of Koha you have. For a package installation, it would be located at the aforementioned path.
The client side configuration is not much more difficult, but must be done on each client.
Step 1 – Download pscp.exe
First, we need an scp client for Windows. The Putty SCP client fits the bill perfectly! You can download it from here. Once downloaded, you’ll need to put it somewhere, such as your home directory. In this example, I will assume it’s saved at C:\Users\Kyle\pscp.exe
Step 2 – Create your command for downloading the borrowers.db file
The command you need to download your file will look similar to this:
C:\Users\Kyle\pscp.exe --pw <password> <username>@<server-address>:/tmp/borrowers.db C:\Users\Kyle\borrowers.db
This command will download the file and put it in your user’s home directory. From here, you can use the “Select Borrowers DB File” under the “Database” menu in the Koha Offline Circulation client to set this as the file to use.
You’ll notice this part requires some configuration. You’ll need to work with your Koha administrator to set up a login and password with which you can download the file. It’s even possible to use ssh keys for password-less downloading, but that is an exercise for another day!
Step 3 – Automating your download
For this part, we need to begin by opening the Windows Task Scheduler. Once it is open, select the “Create Basic Task” option in the “Actions” panel on the right hand side.
First, give the task a name and description.
Next, choose the frequency. If you leave your computers on over night, you can set a particular time for the download to happen ( any time after 8:00 PM in this case, which is when the updated borrowers.db file is generated ). Otherwise, it is best to choose “When the computer starts”
On the next part of the wizard, we need to select “Start a program”.
The following screen is where the action starts. The first action you’ll want to take is to click the “Browse” button and use the file explorer to locate and select the pscp.exe file that you downloaded. After that you’ll need to add in all the parameters you added after the name of the program into the “Add arguments” field ( i.e. “–pw <password> <username>@<server-address>:/tmp/borrowers.db C:\Users\Kyle\borrowers.db” ). Save the action and you should be done!
At this point, you can you can test your schedule action by right clicking on it and running it manually. If the “Date modified” changes to the current time, it worked!
Read more by Kyle Hall