Linux / Unix lftp Command To Mirror Files and Directories

Linux / Unix lftp Command To Mirror Files and Directories

The lftp command is a powerful command-line utility for transferring files and managing FTP, HTTP, and other types of file transfer protocols. It provides a number of features and options that make it easy to transfer files and directories between local and remote systems.

To mirror files and directories using lftp, you can use the mirror command. The mirror command can be used to synchronize a local directory with a remote directory, or vice versa.

Here's an example of how to use the mirror command to synchronize a local directory with a remote directory:

lftp -c "mirror /local/directory/ ftp://user:password@remote.server/remote/directory/"
Sou‮.www:ecr‬lautturi.com

This command will download all the files and directories from the remote directory to the local directory, and also upload any files and directories in the local directory that don't exist in the remote directory.

You can use the --reverse option to reverse the direction of the synchronization. For example, to synchronize a remote directory with a local directory, you can use the following command:

lftp -c "mirror --reverse /local/directory/ ftp://user:password@remote.server/remote/directory/"

There are a number of other options you can use with the mirror command to control the behavior of the synchronization. For example, you can use the --only-missing option to only download files and directories that are missing in the local directory, or the --only-newer option to only download files and directories that are newer in the remote directory.

For more information about the mirror command and other options you can use with it, you can refer to the lftp manual or use the man command to view the manual pages for lftp.

Created Time:2017-10-29 22:08:58  Author:lautturi