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?
Asked
Active
Viewed 4,164 times
1 Answers
0
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!

Maxime Poulin
- 71
- 3
-
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 01 '14 at 05: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 01 '14 at 06: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 01 '14 at 23:50