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?

Noah Kobayashi
  • 111
  • 1
  • 1
  • 4

2 Answers2

9

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.

A.L
  • 10,259
  • 10
  • 67
  • 98
p6majo
  • 277
  • 2
  • 11
  • Hmm. In my case, `-Rne` works exactly as supposed to. Maybe it's dependent on the FTP server? – kralyk Jul 22 '15 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??? – Lukas Lukac Oct 20 '15 at 20:37
  • I also tried this combination without success: "lftp -e ""mirror -c --reverse --only-newer --ignore-time" – Lukas Lukac Oct 20 '15 at 21:03
  • 1
    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 '18 at 04:44
2

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

Ciro
  • 21
  • 1