Advertisement
Guest User

LFTP Sync Script

a guest
Jun 29th, 2018
3,844
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.57 KB | None | 0 0
  1. # amended from https://github.com/Logvin/synctorrents/blob/master/synctorrents.sh
  2. # I take no credit other than amending and pasting here.
  3.  
  4. #!/bin/bash
  5.  
  6. #login information for your remote host, no quotes
  7. login=xxxxx
  8.  
  9. #password information for your remote host, no quotes
  10. pass=xxxxx
  11.  
  12. #host info for your remote host. include full URL standard format is sftp://ftp.servername.com
  13. host=sftp://xxxxx.xxxxx.xxxxx
  14.  
  15. #remote location where your finished downloads are on your seedbox
  16. remote_dir=/where/your/files/are/on/remote/host
  17.  
  18. #local directory where you are storing your downloads for further processing
  19. local_dir=/where/you/want/the/files/to/go/locally
  20.  
  21. #the next few lines checks if lftp is running and stops the script if so.  Will also show the PID if you want to kill the lftp from running manually (although you can use pkill lftp)
  22.  
  23. checkifrunning=`(ps -aux | grep [l]ftp | awk '{print $2}')`
  24. if [[ $checkifrunning ]]; then
  25.   echo "Synctorrent is running already. PID " $checkifrunning
  26.   exit 1
  27. else
  28.  
  29. # Runs the lftp to sync, please amend xxxxx to your ssh / sftp port if required or remove the -p xxxxx option altogether if desired.
  30. # command use-pget-n=20 uses 20 threads, command -P1 does one file at a time.  Amend as needed keeping in mind not flooding your remote host with too many connections.
  31. # command --log=lftp_logs.log will write to the log location you specify, for troubleshooting.  Remove if not needed.
  32.  
  33.   lftp -u $login,$pass $host -p xxxxx << EOF
  34. mirror --use-pget-n=20 -P1 -c --log=lftp_logs.log $remote_dir $local_dir
  35.   quit
  36. EOF
  37.   exit 0
  38. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement