Not the answer you need?
Register and ask your own question!

innobackupex command runs from command-line but not from bash script

computravcomputrav EntrantInactive User Role Beginner
I've got a bash script that I've created to run a backup using innobackupex/xtrabackup, but I'm having an issue actually executing the innobackupex command from the script.

Here is a simplied version of my script highlighting the issue (test.bash):
=======================================
#!/bin/bash

CMD="/usr/bin/innobackupex --user=username --password=password /var/backups/mysql/test &> /var/backups/mysql/test.log"
`$CMD`
=======================================

All this is doing is storing the command I want to execute to a variable and then executing it. In my actual script, the command is constructed from other options and settings, but even this simple script fails. The command itself is running the backup, and storing the output in test.log, and running the command in the background

When I try to run this script (e.g., bash test.bash), I get the error:
innobackupex: Too many command line arguments

However, if I literally copy the command above and then paste into the console at a bash prompt, it runs fine.


Anyone have any idea what's going on here?

Thanks,
Travis

Comments

  • laudareslaudares Percona Support Engineer Percona Staff Role
    Hi Travis,

    you're facing a bash syntax problem - here's a turnaround by indicating the output separated from the innobackupex command itself:

    CMD="/usr/bin/innobackupex --user=username --password=password /var/backups/mysql/test"

    $CMD &> /var/backups/mysql/test.log


    That should do. Let us known, please.

    Regards,

    Fernando
  • computravcomputrav Entrant Inactive User Role Beginner
    Thanks Fernando, that did the trick!!

    -Travis
Sign In or Register to comment.

MySQL, InnoDB, MariaDB and MongoDB are trademarks of their respective owners.
Copyright ©2005 - 2020 Percona LLC. All rights reserved.