Skip to content

Instantly share code, notes, and snippets.

@feralhosting
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save feralhosting/4e7e93a7fecd8f55cb4a to your computer and use it in GitHub Desktop.
Save feralhosting/4e7e93a7fecd8f55cb4a to your computer and use it in GitHub Desktop.
LFTP - Automated sync from seedbox to home SFTP script with generic name
#!/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