BwFileStorage LFTP

From Lsdf
Revision as of 15:23, 3 June 2015 by Obholz (talk | contribs) (Created page with "<H1>Using lftp from UNIX client</H1> '''lftp''' is a command-line file transfer program (FTP client) for UNIX and Unix-like systems. Besides FTP, it also supports HTTP, HTT...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Using lftp from UNIX client

lftp is a command-line file transfer program (FTP client) for UNIX and Unix-like systems.

Besides FTP, it also supports HTTP, HTTPS and SFTP etc.

In addition to features common in advanced FTP clients, such as recursively mirroring entire directory trees and resuming downloads, lftp also supports more advanced functionality. Transfers can be scheduled for execution at a later time, bandwidth can be throttled, transfer queues can be created, and Unix shell-like job control is supported. The client can be used interactively or automated with scripts.

It also has an option called segmented file transfer that allows more than one connection for the same file, bypassing a maximum download speed per file when some servers establish a maximum speed per connection

Installation

Debian:

apt-get install lftp

Suse-Linux:

zypper install lftp

RedHat:

yum install lftp

Documentation

lftp interactive shell

ou can launch lftp by typing just lftp and then using an open command to take you to your target site or you can provide the target's name on the same line

lftp
lftp :~> open -u ka_xy1234 sftp://bwfilestorage.lsdf.kit.edu
Password: 
lftp ka_xy1234@bwfilestorage.lsdf.kit.edu:~> help

or

lftp -u ka_xy1234  sftp://bwfilestorage.lsdf.kit.edu
Password: 
lftp ka_1234@bwfilestorage.lsdf.kit.edu:~>help

Using lftp to mirror/transfer files

#!/bin/bash
# <<EOF below is the functional equivalent of hitting .Enter. on your keyboard.
# It allows the rest of the commands to be executed once connected
#
# mirror [OPTS] [source [target]]
# mirror OPTS:
#      -c, --continue      continue a mirror job if possible
#      -e, --delete         delete files not present at remote site
#      -R, --reverse       reverse mirror (put files)
#      -P, --parallel[=N]  download N files in parallel
#      -v, --verbose[=level]    verbose operation
#      -I GP, --include-glob GP include matching files
#      -r, --no-recursion  donât go to subdirectories
#      ....
lftp -e 'mirror -R /home/localuser/LocalDirToMirror ~/TargetDir' -u YourUsername,YourPassword  sftp://bwfilestorage.lsdf.kit.edu <<EOF
quit 0
EOF

Example 1:

#!/bin/bash
lftp -e 'mirror -P 2 -Re ./testdir  ~/backupdir' -u 'ka_xy1234:password' sftp://bwfilestorage.lsdf.kit.edu <<EOF
quit 0
EOF

Example 2:

#!/bin/bash
lftp -e "mirror -ceR -I '*.tar' ./testdir ~/backupdir;quit" -u 'ka_xy1234:password' sftp://bwfilestorage.lsdf.kit.edu