0

I am using codeship.io to upload files in a code repository to a shared hosting without SSH.

This is the original command, it tooks two hours to complete:

lftp -c "open -u $FTP_USER,$FTP_PASSWORD ftp.mydomain.com; set ssl:verify-certificate no; mirror -R ${HOME}/clone/ /public_html/targetfolder"

I tried to add -n, which is supposed to upload only newer files. But I can still see from the streaming logs that some unchanged files are being uploaded:

lftp -c "open -u $FTP_USER,$FTP_PASSWORD ftp.mydomain.com; set ssl:verify-certificate no; mirror -R -n ${HOME}/clone/ /public_html/targetfolder"

What is the correct command to correctly upload only updated files?

mkto
  • 4,584
  • 5
  • 41
  • 65

2 Answers2

2

The command is correct.

The question is why lftp considers the files "changed". It uploads a file if it is missing, has different size of has different modification time.

You can try to do "ls" on the directory where lftp uploads the files to and see if the files are really present, have the same size and the same or newer modification time.

If for some reason the modification time is older, add --ignore-time to the mirror command.

lav
  • 1,351
  • 9
  • 17
  • 2
    Be careful using --ignore-time because what happens is the file transfer is not sent anymore if the file has changed without size change. For exemple, if file contains "test4" and is changed to "test5" this won't be detected anymore and the file won't be replaced. – Eñaut Nov 26 '20 at 09:33
  • I had the same problem, so I'm using another tool to handle changes. And LFTP only for parallel upload: https://dev.to/arxeiss/parallel-incremental-ftp-deploy-in-ci-pipeline-2511 – Arxeiss Dec 05 '20 at 16:42
0

Codeship builds the code first before deployment.

This means that the code in Codeship's temporary server is newer than anything else in your pipeline, even though the code itself may not have changed.

This is why when you use lftp's option of "only newer files", it simply means everything.

As far as I know, you can't upload only the actual newer files.

FoxInFlame
  • 720
  • 10
  • 20