locked
Copying files from local computer to a remote server RRS feed

  • Question

  • Hello everyone,

    Is there any way to copy files from local computer to a remote server other than mapping the drive and then copying? If so please advise.

    Thank you.
    Wednesday, June 10, 2009 7:32 AM

Answers

All replies

  • Hi Cognic

    I'd advise using robocopy for this. It has builtin functionality for logging, copying permissions etc. It is a component of the windows server 2003 resource kit tools (think it's included in Windows Server 2008) You can download it here:

    http://www.microsoft.com/downloads/details.aspx?familyid=9d467a69-57ff-4ae7-96ee-b18c4790cffd&displaylang=en

    Technical command reference is:

    http://technet.microsoft.com/en-us/library/cc733145.aspx

    or read through robocopy.doc which is also installed when you install the tools.

    If you really want to script copying the files then you could modify some of my code in previous posts.

    http://social.technet.microsoft.com/Forums/en/ITCG/thread/2e9b1f0e-3086-405d-a1d7-dad354e2125c
    http://social.technet.microsoft.com/Forums/en/ITCG/thread/14f2528f-5641-4cd8-926b-3bf1a6d8a1c0

    ...but robocopy is probably the best way to do this. If you get stuck with the command syntax reply back with the error message and i'll fix it up for you.

    Hope this helps,

    Cheers

    Matt :)

    Wednesday, June 10, 2009 11:29 AM
  • Thanks a lot, i'll try robocopy but what if, if i want to copy a specific file(like a file from WINDOWS folder or OS related file) from all servers to one central location?
    Wednesday, June 10, 2009 9:46 PM
  • Hi Cognic

    Robocopy will default to copying "*.*" however you can specify to copy single files only. Cut and paste the command below into notepad and save it as a batch file...EG: robocopy.bat. The following example will copy only "calc.exe" from the "C:\Windows\System32" directory to "C:\Temp" of a remote system where "computerName" is the hostname of the system to copy the file to:

    robocopy.exe "C:\Windows\System32" "\\computername\C$\Temp"  "calc.exe" /copyall /r:2 /log:C:\Logs\robocopy.log"

    The above command assumes you have access to copy the file to the remote share and the "C:\Logs" directory exists. The real benifit of using robocopy is it's ability to copy permissions using the /copyall switch...never use windows explorer to migrate data as it won't copy the permissions. Let me know if you need any further help

    Cheers

    Matt :)

    Thursday, June 11, 2009 12:19 AM
  • Hi Cognic

    If you want to copy a single file from a selection of servers to a central location on a scheduled basis then just modify the command and add an additional line in the batch file for each server to copy the file from...

    robocopy.exe "\\Server1\C$\Windows\System32" "\\serverName\shareName$\Server1" "calc.exe" /copyall /r:2 /log:C:\logs\server1.log
    robocopy.exe "\\Server2\C$\Windows\System32" "\\serverName\shareName$\Server2" "calc.exe" /copyall /r:2 /log:C:\logs\server2.log
    robocopy.exe "\\Server3\C$\Windows\System32" "\\serverName\shareName$\Server3" "calc.exe" /copyall /r:2 /log:C:\logs\server3.log

    This will create a folder for each server in the remote share, copy the file to server's foldername and create a logfile for each server. All you would need to do is run the batch file from a central server as a scheduled task using an account that has permissions to access the C$ share of your servers. Rather than run a script or create a scheduled task on every server to copy the file on a scheduled basis this would pull the file from each server to the central share from a single server...and that way if you need to modify your process (add files to copy) then you just have to update the one batch file and robocopy will do the rest for you.

    Cheers

    Matt :)

    Thursday, June 11, 2009 12:43 AM