2

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?

Relja
  • 678
  • 5
  • 13
  • 25
  • What user is your script running as through `cron`? I'm guessing (don't know) that it's a different user from yours, and that it is missing some permissions you have when logged in. Also, probably not an issue, but you should add some quotes for safety against spaces in filenames: `--incremental-basedir="$LATEST_DUMP"` – cxw Oct 21 '16 at 12:58

1 Answers1

3

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)
Mustafa DOGRU
  • 3,994
  • 1
  • 16
  • 24