Last active
February 7, 2024 00:34
-
-
Save sionta/32e7647cd08a83650049b5e87cd61864 to your computer and use it in GitHub Desktop.
See detailed information https://gist.github.com/sionta/32e7647cd08a83650049b5e87cd61864#gistcomment-3986010
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
/XF | |
Thumb.db | |
desktop.ini | |
/XD | |
$RECYCLE.BIN | |
OneDriveTemp | |
WindowsImageBackup | |
System Volume Information | |
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 | |
@title ROBOCOPY - BACKUP SCRIPTS | |
cd /d "%~dp0" | |
set "OPTIONS=E /J /IM /IT" | |
set "EXCLUDE=JOB:exclude_backup.rcj" | |
:: replace your source path below | |
set "_INTERNAL=D:" | |
:: replace your destination path below | |
set "_EXTERNAL=E:\ResultBackup" | |
:cli | |
set "opt=CLI-Backup Options" & call :help | |
for %%b in (-b backup) do if /i {%1}=={%%b} ( | |
set msg=Backuping | |
set "SOURCE=%_INTERNAL%" | |
set "TARGET=%_EXTERNAL%" | |
) & goto :main | |
for %%r in (-r revert) do if /i {%1}=={%%r} ( | |
set msg=Reverting | |
set "SOURCE=%_EXTERNAL%" | |
set "TARGET=%_INTERNAL%" | |
if not exist "%_EXTERNAL%" goto :error | |
) & goto :main | |
if /i {%1}=={} set "opt=GUI-Backup Options" | |
:gui | |
echo %opt%: | |
echo. | |
echo. [1] Backup from [%_INTERNAL%] to [%_EXTERNAL%] | |
echo. [2] Revert from [%_EXTERNAL%] to [%_INTERNAL%] | |
echo. | |
choice /c 12 /m "What your choice? " | |
if %errorlevel% == 1 ( | |
set msg=Backuping | |
set "SOURCE=%_INTERNAL%" | |
set "TARGET=%_INTERNAL%" | |
) & goto :main | |
if %errorlevel% == 2 ( | |
echo. | |
set msg=Reverting | |
set "SOURCE=%_EXTERNAL%" | |
set "TARGET=%_INTERNAL%" | |
if not exist "%_EXTERNAL%" goto :error | |
) & goto :main | |
goto :EOF | |
:help | |
if {%1}=={/?} goto :usage | |
if {%1}=={-?} goto :usage | |
if /i {%1}=={-h} goto :usage | |
if /i {%1}=={help} goto :usage | |
goto :EOF | |
:usage | |
echo %opt%:&echo. | |
echo. %~n0 [-b ^| backup] from [%_INTERNAL%] to [%_EXTERNAL%] | |
echo. %~n0 [-r ^| revert] from [%_EXTERNAL%] to [%_INTERNAL%] | |
goto :EOF | |
:main | |
echo. Running %opt% to %msg%... | |
if not exist "%CD%\*.rcj" call :exclude | |
ROBOCOPY "%SOURCE%" "%TARGET%" /%OPTIONS% /%EXCLUDE% | |
attrib -r -s -h "%TARGET%" | |
goto :EOF | |
:exclude | |
( @rem option for /JOB:exclude_backup.rcj | |
@echo /XF | |
@echo Thumb.db | |
@echo desktop.ini | |
@echo /XD | |
@echo $RECYCLE.BIN | |
@echo OneDriveTemp | |
@echo WindowsImageBackup | |
@echo System Volume Information | |
)>"%CD%\exclude_backup.rcj" | |
goto :EOF | |
:error | |
echo. Canceled: [%_EXTERNAL%\] was not FOUND. | |
if /i {%1}=={} echo.& pause| echo Press any key to EXIT... | |
goto :EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Preference
Copy Options
For advanced options:
ROBOCOPY /?
/E
/J
/XO
/IS
/IT
/IM
Silent options
Don’t use this option if you want to display log results.
/NS
/NC
/NP
/NFL
/NDL
/NJH
/NJS
Exclude options
Excluded file and folder with options
/JOB:file_exclude.rcj
.file_exlcude.rcj
More Scripts
date_time_new_folder.bat
hide_folder.bat
show_folder.bat