I'm using a shell script which executes lftp mirror --reverse to upload files and directories to a remote server. Just before that it removes everything using glob -a rm -r -f *. The problem is, it is not so fast. Whole operation takes couple of minutes, especially the recursive removal. I'm uploading few megabytes of data in a couple of hundred files, but most of them do not change. I'm connecting through FTPS protocol.


How to improve the performance of my script?

I was thinking about uploading only files that are new or were changed locally and at the same time removing the ones from the remote server that are not present on my local machine. Sadly, I don't know if it is possible or how to achieve it.

Whole script:

lftp $host << EOF

user $username $password
cd $destination_directory
glob -a rm -r -f *
mirror --reverse $local_directory .


1 Answer 1


The solution was at hand. While digging through LFTP manual I found that mirror command has a --delete option which perfectly suits my needs.


delete files not present at the source ~ LFTP Manual

I changed

glob -a rm -r -f *
mirror --reverse $local_directory .


mirror --reverse --delete $local_directory .

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .