FTP download of MySQL Dump using Cron

Hello all, hopefully this is the right section to post this in.

I have several websites hosted on a server that I want to make nightly backups of the MySQL databases. I have setup a cron on the server to do a dump of the database. I have a local server that I want to run another cron job later in the night to ftp into my web server and download those sql dumps. I’ll then just add new database dumps to the cron shell script as I add new databases (as well as run another dump on the web server itself).

I currently have the below script, but when I run it from cron I get the following error:

Output from command /var/www/db-backups.sh …

Login authentication failed
Login failed.
You aren’t logged in
You aren’t logged in
ftp: bind: Address already in use


BEGIN SCRIPT


#!/bin/sh
USERNAME="username"
PASSWORD="password"
SERVER="ftp.mysiteurl.net"

# local directory to store file
DESTDIR="/var/www/sitedir/db-backup"

# remote server directory to retrieve file from
SOURCEDIR="/public_html/db-backup"

# login to remote server
ftp -n -i $SERVER <<EOF
user $USERNAME $PASSWORD
cd $DESTDIR
mget $SOURCEDIR/*.sql
quit
EOF

END OF SCRIPT


Any suggestions would be greatly appreciated, I have limited linux experience (which is why I even started with this local linux box so I can practice. Then I realized I could use it both as a development server, as well as a backup for my web server.

Thanks in advance.
Greg

mysqldump is nice. for transafering i suggest using more secure clients like scp or rsync