Last active
February 21, 2021 23:57
-
-
Save L422Y/5573928 to your computer and use it in GitHub Desktop.
lftp script to mirror remote ftp site to local folder using multiple connections per file and parallel file downloads (for reference/cron jobs)
This file contains hidden or 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/bash | |
do_multisync() { | |
remote_dir="private/files" | |
local_dir="/root/i_drive/files" | |
# remote host | |
host="ftp.myremotehost.com" | |
# username / password | |
user="larry" | |
pass="thisisnotmypassword" | |
# number of connections / parts per file transfer | |
partsperfile=10 | |
# number of parallel transfers at a time | |
numfiles=2 | |
# get number of active multisync processes | |
numprocs=`ps aux | grep "[m]ultisync\$" | wc -l` | |
if [[ $numprocs -gt 2 ]] ; then | |
echo "Previous 'multisync' is still running. ($numprocs)" | |
exit 1 | |
else | |
echo "Running..." | |
( | |
echo open ${host} | |
echo user ${user} ${pass} | |
echo mirror -v -c --use-pget-n=${partsperfile} --parallel=${numfiles} ${remote_dir} ${local_dir} | |
echo bye | |
) | lftp -f /dev/stdin | |
exit 0 | |
fi | |
} | |
do_multisync >> /tmp/multisync.log & | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mirror -v -c --use-pget-n=3 --parallel=2 . .