Last active
November 6, 2019 07:05
-
-
Save bensbrowning/10996904 to your computer and use it in GitHub Desktop.
lftp mirror script for cron
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/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