sftp: upload all files, directories and sub-directories contained in a folder
Hire the world's top talent on demand or became one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Sunrise at the Stream
--
Chapters
00:00 Sftp: Upload All Files, Directories And Sub-Directories Contained In A Folder
00:43 Answer 1 Score 10
01:01 Accepted Answer Score 25
01:45 Answer 3 Score 4
01:56 Answer 4 Score 33
02:08 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/