-
-
Save arthurpham/19fbf7bb4d9d608500cd7464be4d2b88 to your computer and use it in GitHub Desktop.
lftp mirror script for cron
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 | |
login="user" | |
pass="pass" | |
host="foo.bar.com" | |
remote_dir="/path/on/foo/bar/" | |
local_dir="/home/you/foobar-mirror/" | |
log_file="/tmp/lftp-mirror.log" | |
trap "rm -f /tmp/lftp-mirror.lock" SIGINT SIGTERM | |
if [ -e /tmp/lftp-mirror.lock ] | |
then | |
echo "mirror is running already, rm /tmp/lftp-mirror.lock if this is false." | |
exit 1 | |
else | |
touch /tmp/mirror | |
lftp -p 22 -u $login,$pass sftp://$host << EOF | |
set mirror:use-pget-n 5 | |
mirror -c -P5 --Remove-source-files --log="$log_file" $remote_dir $local_dir | |
quit | |
EOF | |
rm -f /tmp/lftp-mirror.lock | |
trap - SIGINT SIGTERM | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment