Search code examples
bashperconainnobackupex

Innobackupex call from bash script


I'm experiencing a really weird behaviour of my innobackupex backup system.

I set it all properly, ran a few backups from terminal and it works good. My idea is to run incremental backups once per day, so I created a small sh script for it to put it into cron:

#!/bin/bash
LATEST_DUMP=$(ls -t /home/power/dbbackup | head -1)
innobackupex --incremental --user=db_user --password=db_password /home/power/dbbackup/ --incremental-basedir=$LATEST_DUMP

Basically, it searches for the latest dump in folder where increments are stored, and use it for another incremental dump. When I try to run it I get the following error

xtrabackup: Error: cannot open 2016-10-21_00-50-30/xtrabackup_checkpoints
xtrabackup: error: failed to read metadata from 2016-10-21_00-50-30/xtrabackup_checkpoints

If I run the same call through terminal command line it works perfect. If I try running this sh script, it throws an error. I used same user for both scripts, the increment folders are readable, xtrabackup_checkpoints file is also readable.

What am I missing?


Solution

  • you can change the following part in your script. LATEST_DUMP should be full path

    LATEST_DUMP="/home/power/dbbackup/"$(ls -t /home/power/dbbackup | head -1)
    

    or

    LATEST_DUMP=$(ls -td /home/power/dbbackup | head -1)