Discussion:
lftp Digest, Vol 25, Issue 15
Robert DuToit
2013-08-25 10:01:52 UTC
Permalink
Hi Alexander,

I tried using your suggestion for mirroring a single file (to use compare of times etc..)
mirror -R -I file_name.ext
but am getting strange results. If I lcd to the directory of the source file (local) and use "mirror -R -I file_name.ext" It will upload the file but also the entire contents of the lcd directory. Do I need to then exclude the directory? Not sure how to do that exactly. I tried "mirror -R -I file_name.ext -x path/to/dir/ " and -x 'path/to/dir/*' but still uploads entire directory. Plus it is a bit cumbersome to have to exclude the directory as this is running from a script. Either way, I can't seem to get it to mirror just the single file

Thanks, Rob
Alexander V. Lukyanov
2013-08-28 07:32:08 UTC
Permalink
Post by Robert DuToit
mirror -R -I file_name.ext
but am getting strange results. If I lcd to the directory of the source file (local) and use "mirror -R -I file_name.ext" It will upload the file but also the entire contents of the lcd directory. Do I need to then exclude the directory? Not sure how to do that exactly. I tried "mirror -R -I file_name.ext -x path/to/dir/ " and -x 'path/to/dir/*' but still uploads entire directory. Plus it is a bit cumbersome to have to exclude the directory as this is running from a script. Either way, I can't seem to get it to mirror just the single file
You also have to disable recursion (-r or --no-recursion). So try this:

mirror -RrI file_name.ext
--
Alexander.
Robert DuToit
2013-08-28 12:20:54 UTC
Permalink
Thanks Alexander,

That works fine. It would be great if I could use the absolute path for the source file since I have a list of files and a lot of lcd calls but it works so I am happy. Thanks for lftp - it has solved a lot of problems. I am making an ftp backup utility for osx and will donate when it's up and running.

Best, Rob
Post by Alexander V. Lukyanov
Post by Robert DuToit
mirror -R -I file_name.ext
but am getting strange results. If I lcd to the directory of the source file (local) and use "mirror -R -I file_name.ext" It will upload the file but also the entire contents of the lcd directory. Do I need to then exclude the directory? Not sure how to do that exactly. I tried "mirror -R -I file_name.ext -x path/to/dir/ " and -x 'path/to/dir/*' but still uploads entire directory. Plus it is a bit cumbersome to have to exclude the directory as this is running from a script. Either way, I can't seem to get it to mirror just the single file
mirror -RrI file_name.ext
--
Alexander.
Alexander V. Lukyanov
2013-08-28 13:33:36 UTC
Permalink
Post by Robert DuToit
That works fine. It would be great if I could use the absolute path for
the source file since I have a list of files and a lot of lcd calls but it
works so I am happy.
I'd recommend to save the list to a file and then use a script to make
lftp commands, like this (of course if the file names do not contain spaces
and other special symbols):

(echo "open ftp://example.com/path || exit"
while read file; do
echo "mirror -Rr `dirname $file` -I `basename $file` ."
done < file-list.txt) | lftp

I can also make an option for mirror to simplify this.
E.g. "mirror -Rf /path/to/file.txt" would automatically translate to
"mirror -Rr /path/to . -I file.txt".

--
Alexander.
Alexander V. Lukyanov
2013-08-30 15:38:03 UTC
Permalink
Post by Alexander V. Lukyanov
I can also make an option for mirror to simplify this.
E.g. "mirror -Rf /path/to/file.txt" would automatically translate to
"mirror -Rr /path/to . -I file.txt".
mirror -Rf /path/to/file.txt"
That would be great and simplify things a bit but it isn't a big deal to get the dirname either.
Anyway, please try this snapshot:
http://lftp.yar.ru/ftp/devel/lftp-pre4.4.10-20130830.tar.gz

It has mirror --file option implemented.

Also it has improved WebDAV support.
--
Alexander.
Robert DuToit
2013-09-01 23:36:53 UTC
Permalink
Post by Alexander V. Lukyanov
Post by Alexander V. Lukyanov
I can also make an option for mirror to simplify this.
E.g. "mirror -Rf /path/to/file.txt" would automatically translate to
"mirror -Rr /path/to . -I file.txt".
mirror -Rf /path/to/file.txt"
That would be great and simplify things a bit but it isn't a big deal to get the dirname either.
http://lftp.yar.ru/ftp/devel/lftp-pre4.4.10-20130830.tar.gz
It has mirror --file option implemented.
Awesome!

Thanks so much Alexander,

Rob
Post by Alexander V. Lukyanov
Also it has improved WebDAV support.
--
Alexander.
Robert DuToit
2013-09-03 13:00:15 UTC
Permalink
Post by Alexander V. Lukyanov
Post by Alexander V. Lukyanov
I can also make an option for mirror to simplify this.
E.g. "mirror -Rf /path/to/file.txt" would automatically translate to
"mirror -Rr /path/to . -I file.txt".
mirror -Rf /path/to/file.txt"
That would be great and simplify things a bit but it isn't a big deal to get the dirname either.
http://lftp.yar.ru/ftp/devel/lftp-pre4.4.10-20130830.tar.gz
It has mirror --file option implemented.
Alexander,

"mirror -R -f path/to/file" is working great. I noticed that in mirror for a ndirectory it logs "transferring path/to/file …. "

Report(_("Transferring file `%s'"),
dir_file(source_relative_dir,file->name));

but for single file it doesn't. I have a progress bar in the UI counting the transfers so it works great. Can you point me to the source where the single file is getting processed, or maybe add a Report(_("Transferring file `%s'") there too? I can't seem to find in MirrorJob.cc where the transfer is being called. Not a C++ person…

It would also be nice in MirrorJob.cc to have a log for skipping files that are not newer etc. I see

Report(_("Skipping file `%s' (only-existing)"),
dir_file(source_relative_dir,file->name));

but that isn't showing for regular mirror jobs.

If you can point me to the code I could add those Reports in for my build, or any suggestions/additions appreciated. If you can - no worry. Thanks for adding the -f option,

Best, Rob
Post by Alexander V. Lukyanov
Also it has improved WebDAV support.
--
Alexander.
Robert DuToit
2013-09-04 12:07:15 UTC
Permalink
Post by Alexander V. Lukyanov
Post by Alexander V. Lukyanov
I can also make an option for mirror to simplify this.
E.g. "mirror -Rf /path/to/file.txt" would automatically translate to
"mirror -Rr /path/to . -I file.txt".
mirror -Rf /path/to/file.txt"
That would be great and simplify things a bit but it isn't a big deal to get the dirname either.
http://lftp.yar.ru/ftp/devel/lftp-pre4.4.10-20130830.tar.gz
It has mirror --file option implemented.
Alexander,

Sorry - my mistake in last email:

in MirrorJob.cc you have

stats.new_files++;
Report(_("Transferring file `%s'"),
dir_file(source_relative_dir,file->name));


This is getting called for the -f option too. I had subbed

Report(_("Transferring file %s"),
source_name);

for directory mirror, which was giving me the absolute source path for file - I need the whole path for the log report.

So that isn't working for single file mirror - I guess source_name is nil in that case because source isn't a dir - not sure. So I can use the dir_file option though it only shows the file name.

Also I still can't seem to get a similar report on files that are skipped .

Sorry about the confusion.

Best, Rob
Post by Alexander V. Lukyanov
Also it has improved WebDAV support.
--
Alexander.
Loading...