Mircea's picture

Hi,

I am pretty new to TurnKey. I have discovered the use of hook scripts for doing backup/restore procedures.

I am using Percona DB server on a TK Core instance and I have created a pre-backup hook script which uses innobackupex utility (part of Percona) to backup all the databases. However, when running tklbam-backup, the hook script runs, creates the backup file, but the file is not included in the actual backup.

Running another tklbam-backup script will include the old backup file, but again, the one created with the second backup hook script will not be included. 

Does anybody knows how can I make the tklbam-backup to include the archive file created with the pre-backup hook script in the same backup of the system ?

I was thinking to this as a workaround : rename /usr/bin/tklbam-backup to something else. Create a new file called : /usr/bin/tklbam-backup, where I will put first the contents of the pre-backup hook script and then run the renamed tklbam-backup script.

Please let me know if there is any other way to accomplish this. 

Thank you.

Forum: 
Jeremy Davis's picture

My suspicion is that it starts dumping the database before the backup takes place but when it checks for files the dump isn't yet created (hasn't finished) so does not get included. I have had a simlar (but different problem) with TKLPatches that import large DBs - the patching process was failing because the import hadn't finished before the patch was otherwise ready to close.

The workaround I used was to import the DB earlier in my script but I suspect that won't work for you (because I imagine that your script is just dumping the DB - nothing else...)

So I can think of 2 workarounds. One would be to just create a cron job to dump the DB a couple of minutes before TKLBAM runs (which I imagine should work). The other would be to test my theory and make the script wait until the dump is complete prior to continuing (and launching TKLBAM). Personally that is what I initially tried with my TKLPatch but couldn't get it to wait for MySQL (not sure why - I tried a number of different commands which should have worked IMO - but no joy).

Add new comment