shell script to backup mysql and lftp - errors

I have a shell script here that works great up until I try to mput a file to a Windows IIS FTP server.  I cannot mput the files manually, however if I connect to another server that is a Linux FTP server, I can put the files normally.

I've done a chmod 777 on the directory where my databases are backing up to, however for some reason I'm still getting a 550 error.  The script is attached.  

The error I'm getting is (you can see it is getting the file names of the mysql backups)

[root@nagios secret]# ./mysql.backup.sh
./mysql.backup.sh: line 7:  : command not found
./mysql.backup.sh: line 12:  : command not found
./mysql.backup.sh: line 18:  : command not found
./mysql.backup.sh: line 20:  : command not found
./mysql.backup.sh: line 27:  : command not found
mkdir: Access failed: 550 /mysql/28-04-2010: The system cannot find the path specified.
cd: Access failed: 550 /mysql/28-04-2010: The system cannot find the path specified.
mput: Access failed: 550 cacti.28-04-2010-11:36:40.gz: The filename, directory name, or volume label syntax is incorrect.
mput: Access failed: 550 information_schema.28-04-2010-11:36:40.gz: The filename, directory name, or volume label syntax is incorrect.
mput: Access failed: 550 mysql.28-04-2010-11:36:41.gz: The filename, directory name, or volume label syntax is incorrect.
mput: Access failed: 550 nagios_config.28-04-2010-11:36:41.gz: The filename, directory name, or volume label syntax is incorrect.
mput: Access failed: 550 taskfreak.28-04-2010-11:36:41.gz: The filename, directory name, or volume label syntax is incorrect.

#!/bin/bash
### MySQL Server Login Info ###
MUSER="backups"
MPASS="backups_password"
# mysql server
MHOST="localhost"
 
### FTP SERVER Login info ###
FTPU="mysqlbackups"
FTPP="ftppassword"
FTPS="server-ip"
 
MYSQL="$(which mysql)"
MYSQLDUMP="$(which mysqldump)"
BAK="/backup/mysql"
GZIP="$(which gzip)"
NOW=$(date +"%d-%m-%Y")
 
[ ! -d $BAK ] && mkdir -p $BAK || /bin/rm -f $BAK/*
 
DBS="$($MYSQL -u $MUSER -h $MHOST -p$MPASS -Bse 'show databases')"
for db in $DBS
do
 FILE=$BAK/$db.$NOW-$(date +"%T").gz
 $MYSQLDUMP -u $MUSER -h $MHOST -p$MPASS $db | $GZIP -9 > $FILE
done
 
lftp -u $FTPU,$FTPP -e "mkdir /mysql/$NOW;cd /mysql/$NOW; mput /backup/mysql/*; quit" $FTPS

Open in new window

JWeb AdminAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Deepak KosarajuDevOps EngineerCommented:
lftp -u $FTPU,$FTPP -e "mkdir /mysql/$NOW;cd /mysql/$NOW; mput /backup/mysql/*; quit" $FTPS

You cannot use / representation when you are trying to write files to window's , use \ representation when you are interact to copy files to windows OS.

lftp -u $FTPU,$FTPP -e "mkdir mysql\$NOW;cd mysql\$NOW; mput /backup/mysql/*; quit" $FTPS

This should work.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JWeb AdminAuthor Commented:
didn't work - same 550 error.  
JWeb AdminAuthor Commented:
Thanks for your help
Deepak KosarajuDevOps EngineerCommented:
Which solution worked for you.
JWeb AdminAuthor Commented:
Yours worked, just used a different FTP server.  I am trying to setup another script to work with our existing Serv-U server as well.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
File Sharing Software

From novice to tech pro — start learning today.