File copy questions

I was transferring around 2TB of data (probably 20 million small files) from one server to the other, and of course we had a network outage when I was about 80% done. With this many small files it took a loooooong time to do this, so I don’t want to start over. In order to not have to completely start over, I was thinking of doing something like this:

$filestoexclude = gci C:\path -recurse

Copy-item "\\server1\path" -Destination C:\path -recurse -exclude $filestoexclude

Just wondering if anyone has any critique or a better way to do this, thanks!

Use robocopy! It’s made for. :wink:

Looks like the /xo /xn options should take care of this. Thanks!

As you stated that the previous attempt was aborted because of a network outage, you should ensure that the files that were being copied to the destination are the same as what they are on the source, and not a corrupted form of it because of the network disruption. You can loop through each file from the source and compare it to the destination and only copy it if it is different on the destination. Otherwise, ROBOCOPY has this functionality using the /MIR argument if you do not require the use of PowerShell.