All pastes #561949 Raw Edit

Mine

public text v1 · immutable
·published 2007-06-12 17:03 UTC
rendered paste body
============ backup_sql.sh ===================
#!/bin/bash
set -x
set -v

INCLUDE=/home/wade/bin/include
. ${INCLUDE}/base.sh

get_target testhost dbdump.sql.gz

============ include/base.sh =================
#!/bin/bash

BASE="/home/wade"

SSH=/usr/bin/ssh
SSH_USER=('-i '${BASE}'/.ssh/backup_id -l backupuser')
SSHCMD="${SSH} ${SSH_USER}"
echo $SSHCMD

RSYNC="/usr/bin/rsync"
RSYNC_CMD=("${RSYNC} -av -e '${SSHCMD}'")
echo $RSYNC_CMD
#
# get_target
# Retrieve files or directories via rsync.  All files are placed in $CWD.
# Argc: 2
# arg1: host
# arg2: path to the file or dir to retreive.
#
get_target ()
{
  target_host="$1"
  target_file="$2"

  target="${target_host}:${target_file}"

  ${RSYNC_CMD} ${target} "."
}


============= Output (the important part) ===================
+ /usr/bin/rsync -av -e /usr/bin/ssh -i /home/wade/.ssh/backup_id -l backupuser testhost:dbdump.sql.gz .
rsync: -i: unknown option
rsync error: syntax or usage error (code 1) at main.c(1084)

=============== Comentary ==============
Obviously, I need to quote the $SSHCMD in RSYNC_CMD so I end up with:
  /usr/bin/rsync -av -e '/usr/bin/ssh -i /home/wade/.ssh/backup_id -l backupuser' testhost:dbdump.sql.gz .

However, I have tried a number of quoting strategies to no avail.  Any suggestions would be greatly appreciated.