Forked from pixeline/mirror_remote_directory_to_local_directory
Created
October 10, 2019 07:23
-
-
Save dreiggy/5bf4f2c5a9bcb392d704bf2fa6faccb5 to your computer and use it in GitHub Desktop.
Bash script using lftp to mirror remote directory to local directory, thus keeping the local directory synchronized with the remote one.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# @author: Alexandre Plennevaux | |
# @description: MIRROR DISTANT FOLDER TO LOCAL FOLDER VIA FTP | |
# | |
# FTP LOGIN | |
HOST='sftp://ftp.domain.com' | |
USER='ftpusername' | |
PASSWORD='ftppassword' | |
# DISTANT DIRECTORY | |
REMOTE_DIR='/absolute/path/to/remote/directory' | |
#LOCAL DIRECTORY | |
LOCAL_DIR='/absolute/path/to/local/directory' | |
# RUNTIME! | |
echo | |
echo "Starting download $REMOTE_DIR from $HOST to $LOCAL_DIR" | |
date | |
lftp -u "$USER","$PASSWORD" $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... | |
mirror --use-pget-n=10 $REMOTE_DIR $LOCAL_DIR; | |
exit | |
EOF | |
echo | |
echo "Transfer finished" | |
date |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment