Tuesday, January 12, 2021

MySQL Autobackup of Koha in Debian/Ubuntu


I am showing you the easiest way to keep automate your koha db backupthat is the combination of MySQL Dumps and a cronjob.

Create a file called mysqldump.sh

mkdir /home/debian/backup/mysqldump.sh

copy the bellow line.

mysqldump -uroot -p******* koha_library | gzip > /home/debian/backup/koha_`date +%F`.sql.gz

save it

Test the script

 chmod +x /home/debian/backup/mysqldump.sh

Create and schedule a new cron job

Execute the script:

 sh /home/debian/backup/mysqldump.sh

And add the following line at the bottom of crontab -e

 30 23 * * * /home/debian/backup/mysqldump.sh

(This will execute the script every day at 23:30.)

------------------------------PERIODIC REMOVAL OF FILES--------------------------

tested on Debian/UBUNTU

  nano /home/debian/backup/mysqldump.sh

Add the line at the end: (this script will remove your Koha backfiles after 7 days)

  find /home/debian/backup/koha* -type f -mtime +7 -exec rm {}

--------------------------Auto Restart Mysql service------------------------------------------

And add the following line at the bottom of crontab -e 

30 23 * * * systemctl is-active  || systemctl start mysql.service

This will run every midnight at 11.30PM



No comments:

How to migrate Linux Dspace to Window 10

Take a backup of Dspace database and folder s Assume the version is same with both OS [I have tested DSpace 6.3] sudo su mkdir dspace_backup...