11

I want to automate to upload files of my websites. But, remote server does not support ssh, so I try lftp command below instead of rsync.

lftp -c "set ftp:use-mdtm no && set ftp:timezone -9 && open -u user,password ftp.example.com && mirror -Ren local_directory remote_directory"

If local files are not changed, no files are uploded by this command. But, I change a file and run the command, all files are uploaded.

I know lftp/ftp's MDTM problem. So, I tried "set ftp:use-mdtm no && set ftp:timezone -9", but all files are uploaded though I changed only one file.

Is anyone know why lftp mirror --only-newer does not transfer "only newer" file?

2 Answers 2

10

On the following page

http://www.bouthors.fr/wiki/doku.php?id=en:linux:synchro_lftp

the authors state:

When uploading, it is not possible to set the date/time on the files uploaded, that's why --ignore-time is needed.

so if you use the flag combination --only-newer and --ignore-time you can achieve decent backup properties, in such a way that all files that differ in size are replaced. Of course it doesn't help if you really need to rely on time-synchronization but if it is just to perform a regular backup of data, it'll do the job.

4
  • Hmm. In my case, -Rne works exactly as supposed to. Maybe it's dependent on the FTP server?
    – kralyk
    Jul 22, 2015 at 21:27
  • lftp -e "mirror --reverse --only-newer --ignore-time /var/www/deploys/project.com/prod/shared/web/images/uploaded_statuses_photos /BACKUP_STATUSES_PHOTOS" -u username,pw server ||| this will copy all files to my backup server, the issue is... I want to setup a cronjob everyday that would backup only new images... the issue is, when I run it again it starts sending all the files again and again. Any idea please??? Oct 20, 2015 at 20:37
  • I also tried this combination without success: "lftp -e ""mirror -c --reverse --only-newer --ignore-time" Oct 20, 2015 at 21:03
  • 2
    Isn't there a minor rest-risk that size-neutral changes are not getting caught & transferred (i.e. minor Typos in text files, possibly uncompressed bitmap-Images…) ?
    – Frank N
    Apr 11, 2018 at 4:44
2

mirror -R -n works for me as a very simple backup of new files

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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