2

I'm running Windows 10, and the server is on Debian 10 and I'm copying a Svelte build directory from my computer to a remote server. I'm using the command to copy the files:

scp -r ./build user@remote.host:~/directory

But there are some files (and entire directories) consistently left out and I end up having to go through and manually copying them over.

Remote directory.

Screenshot.

Local directory; the entire (play) directory is dropped.

Screenshot.

I tried running it with the verbose argument, but it didn't tell me anything special (I think). Why is it doing this, and how can I prevent it?

justsomeguy
  • 357
  • 1
  • 8
Phishy1
  • 23
  • 3

2 Answers2

1

I think that SCP needs a directory structure to exist on the remote server. It will not create folders.

You can use -e flag with rsync, to use a remote shell to carry out the transfer.

rsync -r -e "ssh -p 222" /home/test/dev user@0.0.0.0:/home/remotetest/dev
Giacomo1968
  • 53,069
  • 19
  • 162
  • 212
phi3nix
  • 11
  • 1
  • Why are you using `ssh -p 222`? That is port 222 which is non-standard; it is typically port `22` which doesn’t need a `-p` designation? PS: My answer was posted *after* the original poster indicated that my recommendation of `rsync -avzh ./build user@remote.host:~/directory` should work and they confirmed it did indeed work. – Giacomo1968 Dec 26 '22 at 03:41
-2

I generally use SCP for transferring one file at a time. Or just files matching a pattern from a specific directory. Never for copying a full directory structure

For cases like that, I would use Rsync instead. For example, here is your command translated to an Rsync equivalent:

rsync -avzh ./build user@remote.host:~/directory

Try it out. It should work.

Giacomo1968
  • 53,069
  • 19
  • 162
  • 212
  • Hey! Downvoteders! My answer was posted *after* the original poster indicated that my recommendation of `rsync -avzh ./build user@remote.host:~/directory` should work and they confirmed it did indeed work. – Giacomo1968 Dec 26 '22 at 03:42