Last active
August 29, 2015 14:18
-
-
Save feralhosting/4e7e93a7fecd8f55cb4a to your computer and use it in GitHub Desktop.
LFTP - Automated sync from seedbox to home SFTP script with generic name
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="username" | |
pass="password" | |
host="server.feralhosting.com" | |
remote_dir="/folder/you/want/to/copy" | |
local_dir="/cygdrive/s/lftp/somefolder/where/you.want/your/files/" | |
base_name="$(basename "$0")" | |
lock_file='/tmp/'"$base_name"'.lock' | |
trap 'rm -f '"$lock_file"'' SIGINT SIGTERM | |
if [[ -e "$lock_file" ]] | |
then | |
echo "$base_name is running already." | |
exit 1 | |
else | |
touch "$lock_file" | |
lftp -u $login,$pass $host << EOF | |
set ftp:ssl-allow no | |
set mirror:use-pget-n 5 | |
mirror -c -P5 --log='/var/log/'"$base_name"'.log' "$remote_dir" "$local_dir" | |
quit | |
EOF | |
rm -f "$lock_file" | |
trap - SIGINT SIGTERM | |
exit 0 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment