Created
April 17, 2017 22:05
-
-
Save martok/b9f0121c4a741978105971071934045e to your computer and use it in GitHub Desktop.
Sync/Backup script based on Robocopy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
setlocal | |
echo ************************************************ | |
echo **** Martok's Syncrotron **** | |
echo ************************************************ | |
echo **** 1: Copy from this machine to exHDD **** | |
echo **** 2: Copy from exHDD to this machine **** | |
echo **** anything else: exit **** | |
echo ************************************************ | |
set /p select="Choose option: " | |
set action= | |
if "%select%"=="1" set action=from | |
if "%select%"=="2" set action=to | |
if "%action%"=="" goto :error_noaction | |
set logfile=.\syncrotron_%COMPUTERNAME%_%action%.log | |
set cfgpath=.\%COMPUTERNAME%\%action%\ | |
if not exist %cfgpath%*.rcj goto :error_nojobs | |
if exist %logfile% del %logfile% | |
echo Action: copy %action% this machine | |
echo Press any key to continue... | |
pause > nul | |
for /F "usebackq delims=" %%f in (`dir /ON /B "%cfgpath%*.rcj"`) do robocopy /job:defaults "/job:%cfgpath%%%f" /TEE /LOG+:%logfile% | |
echo Done. | |
pause > nul | |
goto :eof | |
:error_noaction | |
echo No (valid) action specified, exiting. | |
goto :eof | |
:error_nojobs | |
echo No job files found in %cfgpath%, exiting. | |
:eof |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment