automated ftp upload script

Task

Upload backups automatically via ftp.

Explanation

This is a cool bit of code I found that will automate the connection and upload process to an ftp server (I think there are more advanced scripts out there, but this is a start).

ftp -n name.offtpserver.com << EOF
user ftpusername ftppassword
cd /any/ftp/commands
mkdir etc
cd etc
prompt
binary
mput dbbackup.sql filebackup.tar.gz
EOF

Note: Be careful when you upload files this way, that you actually select the correct upload type (be it binary or ascii) – I had been uploading files in this way for some time only to find that none of the backups worked – after some investigation I discovered the cause was that I hadnt specified “binary” as the upload method in my ftp script, and this had corrupted the files!!

Thanks

N/a