How to run cron to autobackup of koha database (only sql) ?
Dear All, I have two questions regarding 1) cronjob and 2) time stamp I would like to know, How to setup cronjob to autobackup of database sql daily ?(before we close the library) Till now, I have enabled Cronjob with localhost:~# cd /usr/share/koha/bin/cronjobs localhost:~# crontab -u root crontab.example /usr/share/koha/bin/cronjobs shows - crontab.example and it has all the required instructions for the cron. I wanted to autobackup of koha db (example: at 5:15 pm daily before library closes) I tried with, following steps. 1. added in crontab -e #ADDED BY SATISH FOR DAILY BACKUP AT 5.15 PM DAILY 15 17 * * * mysqldump -uroot -pmysqlrootpassword dbname | gzip -9 > /home/satish/Dropbox/dbname.sql.gz When I check the dbsize, it is "zero". Therefore, It is not working! 2. by default Koha has /etc/cron.daily koha-run-backups --days 2 --output /var/spool/koha But, It backups when system boots every morning. how to schedule the time for the same? And Koha-run-backups has all the sql and config files backup. But I wanted have only complete db (sql). And also, our library works from 9:30 am to 5.30 pm on week days and 9:30-1:30 pm on every Saturday. (Desktop machine) as server, will be shutdown in the evening everyday until library receives a dedicated server machine. Currently, after setting up- Postfix mail agent, overdue message, advance due notice, check in, check out , new registration notice all are working fine,. but I wanted to setup timings as per the open and closing hours. The checkout Message includes (Notices Section): example Due Date: 20/09/2016 23:59 How to change the Due Date time from 23:59 to 5.30 pm or 17:30 ? My Koha Details are: Version -16.5.01 (upgraded from 3.16.00) OS: Ubuntu - 14.04 server edition (upgraded from 12.04) Install method - Packages Kindly share your best practices? with thanks Satish MV Librarian Govt. Engineering College, Hassan Karnataka. --
I wanted to autobackup of koha db (example: at 5:15 pm daily before
On Sep 19, 2016 10:37 PM, "SATISH" <lis4satish@gmail.com> wrote: library
closes) I tried with, following steps.
1. added in crontab -e #ADDED BY SATISH FOR DAILY BACKUP AT 5.15 PM DAILY 15 17 * * * mysqldump -uroot -pmysqlrootpassword dbname | gzip -9 > /home/satish/Dropbox/dbname.sql.gz
When I check the dbsize, it is "zero". Therefore, It is not working!
The mysqldump syntax looks correct. What user are you running the crontab under? My inclination would be to run the backup under the instance user, using the database user in $KOHA_CONF. Crontabs can get picky about things like $PATH being undefined, so you may need to specify the full path of mysqldump. Also, they look like they use shell syntax, but you should consult 'man 8 crontab' for differences. I'm on my phone, so I can't look up the exact syntax that I use for inserting timestamps into file names, or how that interacts with crontab. I can tell you that I use 'date' in back-ticks, but I'm not sure which arguments I used, whether crontab supports back-ticks (if not, just wrap your call to mysqldump inside a small shell script, and call the script from the crontab).
Hie, I advice you to store user and password for mysql in ~/.my.cnf. So you can simply call as koha user : mysqldump dbname > ... Example : [client] user=kohaadmin password=katikoan host=localhost [mysql] default-character-set=utf8 database=kohadb In this case mysql leads to a connexion with kohadb selected. Not possible for mysqldump, db name must be specified. Regards, Le 21/09/2016 à 14:01, Barton Chittenden a écrit :
On Sep 19, 2016 10:37 PM, "SATISH" <lis4satish@gmail.com> wrote:
I wanted to autobackup of koha db (example: at 5:15 pm daily before library closes) I tried with, following steps.
1. added in crontab -e #ADDED BY SATISH FOR DAILY BACKUP AT 5.15 PM DAILY 15 17 * * * mysqldump -uroot -pmysqlrootpassword dbname | gzip -9 > /home/satish/Dropbox/dbname.sql.gz
When I check the dbsize, it is "zero". Therefore, It is not working!
The mysqldump syntax looks correct.
What user are you running the crontab under?
My inclination would be to run the backup under the instance user, using the database user in $KOHA_CONF.
Crontabs can get picky about things like $PATH being undefined, so you may need to specify the full path of mysqldump. Also, they look like they use shell syntax, but you should consult 'man 8 crontab' for differences.
I'm on my phone, so I can't look up the exact syntax that I use for inserting timestamps into file names, or how that interacts with crontab. I can tell you that I use 'date' in back-ticks, but I'm not sure which arguments I used, whether crontab supports back-ticks (if not, just wrap your call to mysqldump inside a small shell script, and call the script from the crontab). _______________________________________________ Koha mailing list http://koha-community.org Koha@lists.katipo.co.nz https://lists.katipo.co.nz/mailman/listinfo/koha
-- Fridolin SOMERS Biblibre - Pôles support et système fridolin.somers@biblibre.com
participants (3)
-
Barton Chittenden -
Fridolin SOMERS -
SATISH