-1

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.

Question

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 .
exit

EOF
0

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

delete files not present at the source ~ LFTP Manual

I changed

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

to

mirror --reverse --delete $local_directory .

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.