Robocopy Sync Script Example

From PebkacWiki

Jump to: navigation, search
@echo off
REM Mount remote server shares
net use M: \\192.168.50.2\htdocs /USER:<username> <password>
net use N: \\192.168.50.3\htdocs /USER:<username> <password>
net use O: \\192.168.50.4\htdocs /USER:<username> <password>

REM Perform Robocopies
robocopy "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs" M: /MIR /R:0
robocopy "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs" N: /MIR /R:0
robocopy "C:\Program Files (x86)\Apache Software Foundation\Apache2.2\htdocs" O: /MIR /R:0

REM Disconnect Shares
net use M: /DELETE
net use N: /DELETE
net use O: /DELETE

Notes

  • Do not name the script 'robocopy' or it will cause a fork loop with naming calls while processing.
  • The <username> and <password> objects should be the login credentials on the remote server that has atleast Modify permission to the mapped directory.
Personal tools