Code: Select all
#!/bin/bash
# @description: MIRROR DISTANT FOLDER TO LOCAL FOLDER VIA FTP
#
# FTP LOGIN
HOST='127.0.0.1'
USER='ftpuser'
PASSWORD='ftppass'
# DISTANT DIRECTORY
REMOTE_DIR='/remote_dir'
#LOCAL DIRECTORY
LOCAL_DIR='/local_dir'
# RUNTIME!
echo
echo "Starting download $REMOTE_DIR from $HOST to $LOCAL_DIR"
date
lftp -u "$USER","$PASSWORD" -p 21021 $HOST <<EOF
# the next 3 lines put you in ftpes mode. Uncomment if you are having trouble connecting.
#set ftp:ssl-force true
#set ftp:ssl-protect-data true
set ssl:verify-certificate no
# transfer starts now...
set sftp:auto-confirm yes
mirror --only-missing --use-pget-n=5 $REMOTE_DIR $LOCAL_DIR;
exit
EOF
echo
echo "Transfer finished"
date