Prepare Google Drive for Koha backup

Everybody is familiar with using Google Drive. Google Drive is the cloud storage service of Google Inc. Currently, 15 GB of free storage is available with a Google account. Koha users can make use of Google Drive storage to keep database backups. GNOME desktop facilitates synchronising online accounts like Google, Nextcloud, Facebook, Microsoft, Flickr, etc. 

Here are the steps to prepare the Koha system to store the database in Google Drive.

Installation of GNOME desktop

If the system running on desktops other than GNOME, install it. I prefer the GNOME Flashback edition for a minimal and lightweight experience. GNOME Flashback desktop can be installed on the default Ubuntu and Debian desktop. Here is the command to install GNOME Flashback on all Ubuntu variants;

sudo apt update
sudo apt install gnome-session-flashback

Command to install GNOME Flashback on Debian.

sudo apt update
sudo apt install gnome-flashback

Sign out from the current session and change the desktop to GNOME Flashback.


Prepare the system to sync Google Drive

Open the settings, Applications > System Tools > Preferences > Settings 

Select the Online accounts.

Select Google and sign in.

After the successful sign-in, the Google account is visible in the File Manager. Files and folders load into the File Manager when you click on it.




Enter inside the My Drive folder and see the files and folders. Create a folder for Koha's backup. Enter inside the folder for Koha backup and copy the folder's location. It's necessary to direct the database backup to the backup destination.

Copy the folder location and keep it in a file for later use.

The location looks like this, 
google-drive://mygmailaccount@gmail.com/0AHFZ9iUzgfcmUk9PVA/14MJDZzaMNVnosHsOj7r-Xi6bUOHn344e

Scheduling of the backup process

Here is a shell script to schedule the backup with a time stamp. It keeps three days of backup and deletes previous files to save space. Follow the instructions to schedule the backup.

Download the shell script

Copy the shell script to the home folder. Open the shell script and make changes to the Koha database, username, password and location of the backup. The timestamp of the database also appears on the backup file name. Give the number of days the backup keeps.

Move the shell script to /usr/local/bin

sudo cp backup.sh /usr/local/bin

Give the necessary permission to the shell script,

cd /usr/local/bin
sudo chmod +x backup.sh

Create the cronjob entry of the backup. Apply the following command on the terminal.

export EDITOR=mousepad
crontab -e

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

#Koha backup
10 20 * * * /usr/local/bin/backup.sh

Change the timing of the backup. Here, backup takes at 8:10 PM. Watch the backed-up files appear in the folder.

No comments:

Post a Comment