LinuxToolsUncategorized

LFTP Between Servers

Tranfering large directories between servers

First, what is LFTP? Basically its a command-line based FTP (File Transfer Protocol) client that is distrubted as GNU General Public License. You’re not just limited to FTP either. LFTP supports FTP, FTPS, HTTP, HTTPS, FISH, and SFTP.

The biggest advantage simultaneously transferring multiple files between servers in addition to mirroring entire directory trees. There are tons more great features such as scheduling which can be found here.

My use case has been transferring massive amounts of data between servers from Hetzner. 7.5 TBs. A popular use case would be migrating seedboxes between providers.

How do we run it? First you need to make sure it’s installed on your target machine. I’m running Ubuntu and the command is below. It’s does support OpenSuse, Arch Linux, CentOS/Fedor/RHEL and others which you can easily find via Google. Here we go.

$ sudo apt-get install lftp

Now that it’s installed on our target machine lets run it. You’ll need to change the following: Username, Password, Server IP, Port, Source_Dir and Destination_Dir.

Run the following command on your new/destination server.

lftp -u USERNAME,PASSWORD -e "mirror -v -c -P 6 /SOURCE_DIR/ /DESTINATION_DIR/" sftp://SOURCE_SERVERIP:PORT

Press the ENTER key and watch the magic. You’ll have a status line that will rotate every few seconds showing you an eta for the file along with the current speed.

DON’T CLOSE PUTTY OR IT WILL STOP THE SCRIPT. A way around this is to install screen. Here is a nice guard to installing and using it. You can then detach from the session and it will continue to transfer in the background.

Show More

Cory Fiala

Technology and outdoor enthusiast. Anything from desktops to servers with a side of mountain biking and skiing. Life is good!

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button