Every 5 minutes some new files are downloaded via lftp to a local directory. I need to upload to another ftp only the non existing files. My script so far is:
#! /bin/bash
today=$(date +%Y%m%d)
today_files="rec."$today"_"
programa_dir="/home/user/local-dir"
# Download files, that do not exist in the local directory
lftp <<EOF
open -u user,pass ftp1
mget "$today_files*" -O $programa_dir
bye
EOF
# Upload the files
lftp <<EOF
open -u user,pass ftp2
lcd $programa_dir
mirror -R
bye
EOF
The mirror -R command doesn't recognize that only few files do not exist on the remote directory of the second ftp.
Is there a way to fix that? I need only to check the filename's , not the creation or the modification time of the files.
For the second ftp I tried
lftp <<EOF
open -u user,pass ftp2
mput $programa_dir/* -O /
bye
EOF
The result was the same - lftp upload all the files, no only the non existing.
mirror -R -c
)? Maybe it understands to "resume" previous mirror operation by adding only missing files.