Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have 700 binary files (pdf) to download and right now only 400 are available on a sftp server. Can sftp, from the cli, determine what files exist in the local directory so it doesn't need to re-download those files, or will all 700 need to be downloaded and any new files will need to specify the file name?

share|improve this question
up vote 0 down vote accepted

SFTP is the SSH File Transfer protocol, you could use rsync to do just that.

With recursion:

rsync -azP --exclude="*" --include="*.pdf" user@SERVER:/path/to/folder/ /path/to/folder/

Without recursion:

rsync -azP --include '*/' --include '*.pdf' --exclude '*' user@SERVER:/path/to/folder/ /path/to/folder/

Hope it helps!

share|improve this answer
rsync checks whether files exist and doesn't transfer them if so. It also transfers only parts of files if only parts have changed. Unfortunately, there's no way to get sftp to do this in itself, though if essential you could use find to determine new file names and just copy those. However, since SFTP runs over SSH, if you possibly can, as rsync runs over SSH also, you'd get a far superior result by implementing rsync-over-ssh. – Brian C Mar 1 '14 at 5:15
Thanks Maxime! Using rsync is probably a better solution for this. sftp works well for getting all my files securely, though. – Registered User Mar 1 '14 at 6:57
Keep mind SSH is as secure as SFTP. However keep in mind that your SFTP version affects the functional features, but it does not affect security of the connection which is always SSH2. – Maxime Poulin Mar 1 '14 at 23:50

Your Answer


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.