Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use robocopy to copy directories on different domains [closed]

I want to copy a directory(abc) from domain1/user1 to domain2/user1. any idea how to do this. e.g robocopy

robocopy \\server1\G$\testdir\%3 \\server2\g$\uploads

and both are on different domains

like image 704
sam Avatar asked Apr 27 '12 07:04

sam


People also ask

Does Robocopy work over network?

Using Robocopy over the network is a two-step process. You must first configure file sharing on the source device and then use Robocopy in the destination device to perform the transfer.

Can Robocopy copy folders?

The Basics: Copying Files The most basic use of robocopy is using a source and destination directory with no options. This option will copy all files (excluding subfolders) from C:\src to C:\dst. You can also copy everything including subfolders (empty or not) and NTFS permissions.

How do I transfer Robocopy from one server to another?

Robocopy \\servername\d$\folder \\servername\E$\folder1\folder2\Dept\Accounting /E /ZB /COPYALL /MIR /R:0 /W:0 /V /TEE /log:"c:\temp\f_Copy.

Does Robocopy copy subfolders by default?

Robocopy does not copy subdirectories by default. copy subdirectories, including Empty ones. Same as /S, but it also copies empty subdirectories. Will automatically add /S into the command.


1 Answers

Robocopy will use the standard windows authentication mechanism.

So you probably need to connect to the servers using the appropriate credentials before you issue the robocopy command.

You can use net use to do this and you could put that in a batch script.

Note that Windows doesn't like you to connect to the same server with two different sets of credentials (so you can't copy from and to the same server as different users). But that's not what it looks like you need.

Something like this:

net use \\server1\g$ /user:domain1\user1 * 
net use \\server2\g$ /user:domain2\user2 *
robocopy \\server1\G$\testdir\%3 \\server2\g$\uploads

Notes:

  • This is using 'deviceless' connections which will not be recreated at start up (and won't appear with a drive letter in windows explorer).
  • The asterisk at the end of the net use command means prompt for password, you could hard code the password in there (or get it as a parameter to the script).
  • Might be worth reading up on net use to make sure it does what you need.

You can probably also remove the network connection to the servers by using this (I haven't tried this with a deviceless connection):

net use \\server1\g$ /delete
net use \\server2\g$ /delete
like image 107
GregHNZ Avatar answered Oct 11 '22 06:10

GregHNZ