I have a backup script for my server that mostly works. Only the the rsync commands throw an error in the log I can't find a solution to.

Here's part of my script (I removed the working stuff):


TIMESTAMP=`date +%Y%m%d_%H%M`


function log () 
    now=$(date +"%T")
    echo -e "$now: $1"

echo -e "Starting backup..."

if [ ! -d "$BKDIR" ]; then
        echo -e "Creating Backup directory $BKDIR..."
        mkdir -p $BKDIR
        mkdir -p $BKDIR/games
        mkdir -p $BKDIR/games/minecraft

# Redirect all output to log
exec >> $LOG 
exec 2>&1

log "Saving Minecraft..."
`/usr/bin/rsync -av /var/games/minecraft $BKDIR/games/minecraft --exclude 'plugins/dynmap/web'`

# Sleeping 10 seconds to allow file access
sleep 10

# Compressing backup
log "Compressing backup to $BKROOT/backup_$TIMESTAMP.tar.gz..."
`/bin/tar czvfP $BKROOT/backup_$TIMESTAMP.tar.gz "$BKDIR"`
if [[ $? != 0 ]]; then
    log "Error during compression"
    log "Compression OK"

# Uploading backup to Backup storage
log "Uploading backup and log to Backup storage..."
`/usr/bin/scp $BKROOT/backup_$TIMESTAMP.tar.gz user@server.domain:/`
if [[ $? != 0 ]]; then
    log "Error during upload of backup"
    log "Uploading of backup OK"
`scp $LOG user@server.domain:/`
if [[ $? != 0 ]]; then
    log "Error during upload of backup log"
    log "Uploading of backup log OK"

TIMEEND=`date "+%m/%d/%Y @ %H:%M"`

# Logging free space on backup location
echo 'df -h' | sftp user@server.domain.de

# Sending mail
`echo "Done" | mutt -s "Backup completed on $TIMEEND" -i $LOG user@domain.com`

# Removing backup folder
echo -e "Removing temporary folder"
log "Removing temporary folder..."
`rm $BKDIR -rf`

The script is running as root via cronjob. Everything is working fine, except the rsync commands. Every single one of them is writing the following error into the logfile:

20:19:38: Saving Minecraft...
/home/roots/scripts/backup.sh: line 126: sending: command not found
20:21:40: Backup of www-data files
/home/roots/scripts/backup.sh: line 141: sending: command not found
/home/roots/scripts/backup.sh: line 142: sending: command not found
20:23:03: Copying FHEM backups
/home/roots/scripts/backup.sh: line 157: sending: command not found

All 4 rsync commands have the exact same parameters except for the source and destination paths.

The server is running Ubuntu 16.04.2 LTS (Xenial Xerus).

Anyone got an idea what I did wrong?

  • Your shell script is only 71 lines long, while the errors are from lines well above that. Is rsync really at /usr/bin/rsync ? (test this with which rsync in a shell)
    – thrig
    Jun 22, 2017 at 19:22
  • The actual script is a lot longer - I just cut out all the working parts to keep it cleaner. Yes, rsync is at /usr/bin/rsync
    – adiuva
    Jun 22, 2017 at 19:23

1 Answer 1


You have lines like this:

`/usr/bin/rsync -av /var/games/minecraft $BKDIR/games/minecraft --exclude 'plugins/dynmap/web'`

The backticks mean to execute the output of the command in between them. So the rsync command runs, creates some output, and the shell tries to execute that output. Simply remove the backticks and you'll be okay:

/usr/bin/rsync -av /var/games/minecraft $BKDIR/games/minecraft --exclude 'plugins/dynmap/web'
  • You were right. Thank you very much for the explaination!
    – adiuva
    Jun 22, 2017 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.