Bash Shell Script to Automate FTP File Transfer

A little script to send a backup file to a remote FTP server:

#!/bin/bash
HOST='123.111.123.111'
USER='bak_user'
PASSWD='OpEnSeSaMe'
TODAY="$(date +"%Y%m%d")"
FILENAME=Hostname_$TODAY.tgz
cd /var/backup/sched/
ftp -n -v $HOST << EOT
ascii
user $USER $PASSWD
prompt
cd backups
put $FILENAME
ls -la
bye
EOT

Then run it every day from Cron.

Leave a Reply

  • (will not be published)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>