New
#260
Hi,
I was looking for a simple backup programm, utility, ... to backup my files. The program should be portable. I like to backup one time all files (full backup) and then for the next seven times the difference (differential or incremental backup).
I tried to tweak robocopy to make differential backups. With the option /MAXAGE I think I found a solution even if it's not a real differential backup because it's based only on date and not on date and time.
I took the script from Post 13 and modified it.
Some explanations:
- robocopy didn't work correctly without administrator privileges. So I check that with fsutil.
- I would like to use TARGETDIR as a variable in for example TARGETFULL. But that didn't work. So I wrote the target directory in all other TARGET variables.
- The first time a full backup is made the delete command fails.
Can anybody have a look on my modified script?
Best regards, FrankCode:echo off mode con lines=45 cols=125 :Start call :isAdmin if %errorlevel% == 0 ( GOTO Menu ) else ( echo Error: No administrator privileges. GOTO Quit ) :isAdmin fsutil dirty query %systemdrive% >nul exit /b :Menu cls echo. echo ****************************** echo *** Robocopy Backup Script *** echo ****************************** echo. echo 1 - Run ROBO #1 - Full echo 2 - Run ROBO #2 - Diff echo 3 - Exit echo. echo ****************************** echo. set day=%date:~-10,2% set month=%date:~-7,2% set year=%date:~-4% set hour=%time:~-11,2% set minute=%time:~-8,2% set second=%time:~-5,2% set source="<put_source_dir_here>" set targetdir="<put_target_dir_here>" set targetfull="<put_target_dir_here>\Full\%year%.%month%.%day%-%hour%.%minute%.%second%" set targetdiff="<put_target_dir_here>\Diff\%year%.%month%.%day%-%hour%.%minute%.%second%" set logfilefull="<put_target_dir_here>\%year%.%month%.%day%-%hour%.%minute%.%second%.full.log" set logfilediff="<put_target_dir_here>\%year%.%month%.%day%-%hour%.%minute%.%second%.diff.log" SET /P M=Type 1, 2 or 3 then press ENTER: IF %M%==1 GOTO Full IF %M%==2 GOTO Diff IF %M%==3 GOTO Quit :Full del "%targetdir%\*.last_full" robocopy "%source%" "%targetfull%" /MIR /R:3 /W:3 /V /LOG+:"%logfilefull%" /TEE type NUL > "%targetdir%\%year%%month%%day%.last_full" pause GOTO MENU :Diff For /F %%i in ('dir /B %targetdir%\*.last_full') do set last_full=%%~ni robocopy "%source%" "%targetdiff%" /MAXAGE:%last_full% /R:3 /W:3 /V /LOG+:"%logfilediff%" pause GOTO MENU :Quit pause