4

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?

Phishy1
  • 43

3 Answers3

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
  • 58,727
phi3nix
  • 111
0

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
  • 58,727
-1

I just had the same issue, and it was most probably caused by this bug: https://github.com/PowerShell/Win32-OpenSSH/issues/1897

SCP fails with a recursive copy with a directory structure greater than eight folders deep. Directories up to the 8th directory are created in the destination, but no directories deeper than the 8th directory are created. No files are copied at all.

In my case actually most files were copied, but some files were missing - not only from directories 8 levels down, but also from higher directory levels.

The malfunctioning scp version on my Windows 10 (with all updates) was version 8.1.0.1. I installed openssh v9.5.0.0p1 from scoop instead and it works without issues.

h86
  • 1