The Computer Oracle

sftp: upload all files, directories and sub-directories contained in a folder

-------------------------------------------------------------------------------
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
-------------------------------------------------------------------------------

Track title: CC C Schuberts Piano Sonata No 13 D

--

Chapters
00:00 Question
01:02 Accepted answer (Score 24)
01:59 Answer 2 (Score 31)
02:20 Answer 3 (Score 10)
02:42 Answer 4 (Score 4)
02:56 Thank you

--

Full question
https://superuser.com/questions/387477/s...

--

Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...

--

Tags
#sftp #put

#avk47



ANSWER 1

Score 33


In sftp this command recursively uploads content of the current directory to the remote current directory:

 put -r .

See man sftp.




ACCEPTED ANSWER

Score 25


Although not strictly equivalent to sftp, rsync is a very powerful alternative for scp and sftp, especially when updating the copies from machine A to machine B, as it doesn't copy the files that haven't been altered; it's also able to remove files from machine B that have been deleted from machine A (only when it's told to of course).

In your case, the syntax would be

rsync -zrp /home/a/ user@remote.host.com:/home/b/

The -r option is for recursively copying files, -z enables compression during the transfer, and -p preserves the file permissions (file creation, edit, etc.) when copying, which is something that scp doesn't do AFAIK. Many more options are possible; as usual, read the man pages.




ANSWER 3

Score 10


scp (secure copy) is the Linux de facto for transferring files over a secure tunnel. In your case you would want to use the recursive switch, e.g.:

scp -r /home/a/ user@remote.host.com:/home/b/



ANSWER 4

Score 4


Try using

put -r /home/a/ /home/b/

for more info check out: this