Advertisement
J2897

Robocopy - Mirror

Oct 13th, 2015
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Batch 1.35 KB | None | 0 0
  1. :: Released under the GNU General Public License version 3 by J2897.
  2.  
  3. :: This script will create an exact mirror of the files in the SOURCE folders in the DESTINATION folders. The timestamps will be preserved. The security permissions will be disgarded.
  4.  
  5. :: WARNING: Anything that has been deleted from the SOURCE will be automatically deleted from the DESTINATION. So be careful!
  6.  
  7. :: Note: If you don't want files to be automatically deleted from the DESTINATION folders, use the Copy script instead: http://pastebin.com/mZYjpT1S
  8.  
  9. @echo OFF
  10.  
  11. REM Custom variables.
  12. set "TASKNAME=Mirror again"
  13. set "SOURCE=\\NAS1\FreeNAS"
  14. set "DESTDRIVE=J:"
  15. set "DESTINATION=%DESTDRIVE%\NAS1\FreeNAS"
  16.  
  17. REM Fixed variables.
  18. set "LOGFOLDER=%USERPROFILE%\RoboCopy Logs"
  19. set "LOGFILE=%LOGFOLDER%\%TASKNAME%.log"
  20. set "TAB=   "
  21.  
  22. REM Preparation.
  23. title %TASKNAME%
  24. pushd "%~dp0"
  25. if not exist "%LOGFOLDER%" (md "%LOGFOLDER%")
  26.  
  27. REM Display.
  28. echo Mirroring . . .
  29. echo.
  30. echo SOURCE:%TAB%%TAB%%SOURCE%
  31. echo DESTINATION:%TAB%%DESTINATION%
  32.  
  33. REM Main Robocopy command.
  34. robocopy.exe "%SOURCE%" "%DESTINATION%" *.* /MIR /NP /R:100 /W:30 /Z /LOG:"%LOGFILE%" /XJ /XD "%DESTDRIVE%\$RECYCLE.BIN" "%DESTDRIVE%\System Volume Information" /XF "desktop.ini"
  35.  
  36. REM Finish up.
  37. explorer /select,"%LOGFILE%"
  38. popd
  39. echo.
  40. pause
  41.  
  42. :End
  43. echo.
  44. echo Ending . . .
  45. timeout /t 4 /nobreak >nul
  46. exit /b 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement