Putting and renaming a file
A file can be put and renamed in one step with the -o
option:
put local-file.name -o remote-name-of.file
Using the star to reference multiple file
A command (like rm
) can be prepended with glob
which will expand the star to matching file names:
glob rm *
However, in order to use globbing with put
, the standard(?) mput
command should be used.
Mirroring from one server to another
lftp is useful because it has a mirror
command to download or update a whole directory tree. With -R
, this mirror mechanism is reversed: it uploads or updates a directory tree on a server.
Local files to remote ftp server
The following mirrors the tree structure under the local current directory to the remote current directory (which, after cd
is httpdocs/path/to/directory
).
The -R
stands for reverse so that files are put rather than get.
$ lftp ftp.host.xyz
cd httpdocs/path/to/directory
mirror -R
Upload only files that are not present on the server
mirror -R --only-missing
Keeping file permissions
In order to retain file permissions, apparently, --no-umask
should be applied when downloading and --perms
when uploading. (or --no-perms
?).
But it does not really work.
Better was to temporarly execute umask 000
before downloading.
Cache
Apparently, lftp likes to cache the remote content of a directory. So, the output of ls
won't change when some other process adds or removes a remote file.
The cache of lftp can be flushed, however:
cache flush
ls
will then retrieve an updated directory content.