Discuss your project
Linux Shell

shell: mirror a directory with lftp

Migrating a large website (several gigabytes) can be a tedious task to do from your workstation (with filezilla, for example). If you have a machine at a hosting provider with shell access, the lftp solution can quickly prove to be the ultimate alternative....

shell: mirror a directory with lftp

Migrating a large website (several gigabytes) can be a tedious task to do from your workstation (with filezilla, for example). If you have a machine at a hosting provider with shell access, the lftp solution can quickly prove to be the ultimate alternative.

Retrieve the files:

lftp -e 'mirror /repertoir/distant /repertoir/local' -u login,password -p 21 www.host.com

Send the files:

lftp -e 'mirror -R /repertoir/local /repertoir/distant' -u login,password -p 21 www.host.com

Send the files with 10 simultaneous connections:

lftp -e 'mirror --parallel=10 -R /repertoir/local /repertoir/distant' -u login,password -p 21 www.host.com

Precautions before executing the order

This tutorial retains the command and the context of its publication. Before using it on a current repository, inspect the branch, the modified files, and the exact target:

git status --short
git log --oneline --decorate -5

Create a backup branch or tag when the operation rewrites history or deletes files. In particular, git reset --hard overwrites the changes in the working directory.

Reference: official documentation of git reset.

Share this article