My Blog List


Monday, June 12, 2023

How to autobackup koha database in google drive via rclone

 Install Rclone on the Ubuntu





(Rclone is a command-line program to manage the files on cloud storage. we can synchronize or mount the directory, files, and databases with the cloud  storage e.g.  Google Drive.)

update & upgrade the server

sudo apt update 

sudo apt upgrade

Install the Rclone

sudo apt install rclone 

After installing the Rclone we need to configure it. Enter the following command. 

rclone config


Enter ‘n‘ to add a new remote.


Enter the name of the new remote. Here I put the name 'Googledrive' as we are going to configure it to back up in Google drive.




Select cloud service as google drive from the list to send Backup. We need to enter the number of the cloud service. So enter the correct number of the Google drive. In my case, it is 13 for google drive.



Hit Enter Twice  (to leave blank for client id and Client secret id)


Select the permission type and enter the '1' number to give full access.




Hit enter twice (to leave blank Root Folder id and service account file)




Enter 'N' as we don't need advanced configuration.



Enter 'Y' to use auto-config.



When you put ‘Y’ and hit enter, A popup window will appear, where you need to log in with your Google account. It will ask permission. Click on the 'Allow' button. If the popup window does not appear automatically then copy the link which appeared in the terminal, locate it in the browser and allow permission.




After allowing permission you have configured the rclone successfully.




Now Enter 'Y" to  configure this as a team drive




Enter 'Y' to confirm ok




Enter 'Q' to get out from the configuration and enter in the sudo or root user.




Now create a backup folder in the home directory named kohabackup 

mkdir ~/kohabackup

Apply the following command to send backup from the "kohabackup" folder to Google drive

rclone mount Googledrive: ~/kohabackup

Close the terminal and open it again

Now create a crontab to schedule backup in "kohabackup" folder 

Apply the following command to open crontab in the terminal

crontab -e

Add the below lines at the bottom of the file (for more detail see also )

30 13 * * * mysqldump -ukoha_library -ppassword koha_library | xz > /home/kohabackup/koha_library.sql.xz

No comments:

Post a Comment