Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I need to transfer a large number of files from an FTP server to a new server. There could be thousands of files so I would like to limit it to files that were uploaded in the last three months - is that possible and if so how?

Also is it possible to find out how big the download is likely to be before you start the actually download?

Thanks

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

You can use lftp for that, utilizing its mirror command. Here's a snip from the manpage:

  mirror [OPTS] [source [target]]

   Mirror specified source directory to local target directory. If target
   directory  ends  with  a  slash,  the source base name is appended to 
   target directory name. Source and/or target can be URLs pointing to 
   directories.


[cut...]
        -N, --newer-than=SPEC    download only files newer than specified time
            --on-change=CMD      execute the command if anything has been changed
            --older-than=SPEC    download only files older than specified time
[...]

Definitely have a look at the manual, as there are really many useful options to mirror - like --allow-chown, --allow-suid or --parallel[=N] for example. Lftp also works with other access protocols, like sftp, fish or http(s).

share|improve this answer
    
Perfect. Thanks! –  williamsdb Mar 27 '12 at 11:51
add comment

You could try mounting it as a filesystem using curlftpfs.
Then copy using find.
e.g:

mkdir /tmp/mountpoint
curlftpfs ftp://example.com/ /tmp/mountpoint/
cd /tmp/mountpoint
find -mtime +90 -exec cp {} /dest/path/ \;

I suspect better solutions exist.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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