Skip to content

Instantly share code, notes, and snippets.

@L422Y
Last active February 21, 2021 23:57
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save L422Y/5573928 to your computer and use it in GitHub Desktop.
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)
#!/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 &
@L422Y
Copy link
Author

L422Y commented May 24, 2013

mirror -v -c --use-pget-n=3 --parallel=2 . .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment