I am creating a script where I want to upload files from local directory to remote directory but based on some condition I am calculating the files count and upload the files.
So I need file difference count to finish my script.
diff -q dir1/ dir2/ | wc -l is working fine in local but that same command is not working with lftp
lftp -e "set ftp:ssl-allow no; diff -q /XXXXX/Y/ tmp/A_000/ | wc -l; bye" -u username,password remote_storage_url
where /XXXXX/Y/ is the remote path and tmp/A_000/ is my local path.
Well diff command is not supported command in lftp but I need solution for this issue.
Edit-1:
I have tried mirror command with --dry-run, but the problem is the actual command shows how many files are transferred and --dry-run does not shows it.
With actual run:
jayesh@ubuntu:~/test$ lftp -e "set ftp:ssl-allow no; mirror -R tmp/A_000/ /XXXXX/Y/ ; bye" -u username,password remote_storage_url
New: 11 files, 0 symlinks
19046373 bytes transferred in 50 seconds (371.8 KiB/s)
To be removed: 0 directories, 11 files, 0 symlinks
With --dry-run:
jayesh@ubuntu:~/test$ lftp -e "set ftp:ssl-allow no; mirror -R tmp/A_000/ /XXXXX/Y/ --dry-run ; bye" -u username,password remote_storage_url
mkdir -p ftp://username:password@remote_storage_url/%2F/XXXXX/Y/
To be removed: 0 directories, 11 files, 0 symlinks
I want file count to be added before I do actual upload.
You can try mirror with the option --dry-run or —-script, then interpret the log.