Great job. Thanks for sharing this. I have used your code to improve my own incremental backup script. Our two scripts now differ only in the following way:1. In addition to folder exclusion, I also exclude certain files; e.g., I use the following:set EXF=thumbs.db ethumbs.db desktop.ini *.tmp *.hdmp *.blf {* .DS_Store ._DS_StoreThen amend the robocopy command lines with:/XF %EXF%2. I include a call to a separate batch file that creates environmental variables for time and date parameters:CALL DateTimeFunctionsThis makes the routine international. (Your script as is will fail in Europe, for example.)It also keeps my backup script concise, since I use this same date-time batch for other purposes.I've included my version of DateTimeFunctions.bat below, which includes references to the original author and some testing code at the end. It may be necessary to add SETLOCAL and ENDLOCAL to the top and bottom of the final script, and make minor adjustments to variable names.Thanks again.@echo off:: http://www.computerhope.com/forum/index.php?topic=76081.msg497599#msg497599:: http://www.computerhope.com/forum/index.php?topic=72945.0:: Code published in the above two pages has been combinedset vbsfile=newdate.vbsecho Newdate = (Date())>%vbsfile%echo DateYear = DatePart("YYYY", Newdate)>>%vbsfile%echo DateMonth = DatePart("M" , Newdate)>>%vbsfile%echo DateDay = DatePart("D" , Newdate)>>%vbsfile%echo WeekOfYear = DatePart("WW" , Newdate)>>%vbsfile%echo DayOfYear = DatePart("Y" , Newdate)>>%vbsfile%echo WeekDayNumber = DatePart("W" , Newdate)>>%vbsfile%echo TodayNameShort = WeekdayName(WeekDayNumber,True)>>%vbsfile%echo TodayNameFull = WeekdayName(WeekDayNumber,False)>>%vbsfile%echo MonthNameShort = MonthName(DateMonth,True)>>%vbsfile%echo MonthNameLong = MonthName(DateMonth,False)>>%vbsfile%echo TimeHour = Hour(Time)>>%vbsfile%echo TimeMinute = Minute(Time)>>%vbsfile%echo TimeSecond = Second(Time)>>%vbsfile%echo If TimeHour^<12 Then>>%vbsfile%echo AMorPM="AM">>%vbsfile%echo Else>>%vbsfile%echo AMorPM="PM">>%vbsfile%echo End If>>%vbsfile%echo Wscript.Echo DateYear^&" "^&DateMonth^&" "^&DateDay^&" "^&Week^OfYear^&" "^&DayOfYear^&" "^&WeekDayNumber^&" "^&Today^NameShort^&" "^&TodayNameFull^&" "^&MonthNameShort^&" "^&MonthNameLong^&" "^&TimeHour^&" "^&Time^Minute^&" "^&TimeSecond^&" "^&AMorPM>>%vbsfile%for /f "tokens=1-14 delims= " %%A in ('cscript //nologo %vbsfile%') do (set Year=%%Aset Month=%%Bset Day=%%Cset WeekNumber=%%Dset DayNumber=%%Eset DayOfWeekNum=%%Fset DayNameShort=%%Gset DayNameLong=%%Hset MonthNameShort=%%Iset MonthNameLong=%%Jset TimeHour=%%Kset TimeMinute=%%Lset TimeSecond=%%Mset TimeAMPM=%%N)::----- ADJUST VALUES LESS THAN 10IF %Day% LEQ 9 SET Day=0%Day%IF %Month% LEQ 9 SET Month=0%Month%IF %TimeHour% LEQ 9 SET TimeHour=0%TimeHour%IF %TimeMinute% LEQ 9 SET TimeMinute=0%TimeMinute%IF %TimeSecond% LEQ 9 SET TimeSecond=0%TimeSecond%GOTO :EOFecho.echo Date Year : %Year%echo Date Month : %Month%echo Date Day : %Day%echo Week Of Year : %WeekNumber%echo Day Of Year : %DayNumber%echo Day Of Week [Number] : %DayOfWeekNum%echo Day Of Week [Short Name] : %DayNameShort%echo Day Of Week [Full Name] : %DayNameLong%echo Month [Short Name] : %MonthNameShort%echo Month [Long Name] : %MonthNameLong%echo Time Hour : %TimeHour%echo Time Minute : %TimeMinute%echo Time Second : %TimeSecond%echo.echo %DayNameLong%, %MonthNameLong% %Day%, %Year% is in week %WeekNumber%echo.pause
Any possibility I can get a copy of your backup? *** Email address is removed for privacy ***
A colleague and I have come up with the following so far but neither of us are coders thank you in advance:
@echo off
call :MsgBox "This Utility will back up all of a users important data including Documents, Picutures, Favorites, Mapped Drives/Printers and Outlook data. Please ensure all applications are closed. Are you ready to run the backup?" "VBYesNo+VBQuestion"
"Click Yes to continue or No to exit"
if errorlevel 7 (
echo NO - closing
) else if errorlevel 6 (
echo YES - running scripts
Robocopy "C:\documents and settings\%username%\Desktop" D:\backup\%username%\Desktop *.* /e /TEE /LOG:Backupstats.log
Robocopy "C:\documents and settings\%username%\Favorites" D:\backup\%username%\Favorites *.* /e /TEE /LOG+:Backupstats.log
Robocopy "C:\documents and settings\%username%\Documents" D:\backup\%username%\Documents *.* /e /TEE /XJ /LOG+:Backupstats.log
Robocopy "C:\documents and settings\%username%\Pictures" D:\backup\%username%\Pictures *.* /e /TEE /XJ /LOG+:Backupstats.log
Robocopy "C:\documents and settings\%username%\application data\microsoft\signatures" D:\backup\%username%\signatures *.* /e /TEE /LOG+:Backupstats.log
Robocopy "c:\documents and settings\%username%\application data\microsoft\Outlook" D:\backup\%username%\NK2 *.nk2 /TEE /LOG+:Backupstats.log
Robocopy "c:\documents and settings\%username%\application data\microsoft\templates" D:\backup\%username%\templates normal.dot /TEE /LOG+:Backupstats.log
Robocopy "c:\users\%username%\appData\Local\Microsoft\Office" D:\backup\%username%\Local *.Officeui /TEE /LOG+:Backupstats.log
Robocopy "c:\users\%username%\appData\Roaming\Microsoft\Office" D:\backup\%username%\Roaming *.Officeui /TEE /LOG+:Backupstats.log
regedit /e D:\backup\%username%\CustomDictionaries.reg "HKEY_CURRENT_USER\Software\Microsoft\Shared Tools\Proofing tools\Custom Dictionaries"
regedit /e D:\backup\%username%\Drives.reg "HKEY_CURRENT_USER\Network\"
regedit /e D:\backup\%username%\Printers.reg "HKEY_CURRENT_USER\Printers"
echo Done
)
exit /b
:MsgBox prompt type title
setlocal enableextensions
set "tempFile=%temp%\%~nx0.%random%%random%%random%vbs.tmp"
>"%tempFile%" echo(WScript.Quit msgBox("%~1",%~2,"%~3") & cscript //nologo //e:vbscript "%tempFile%"
set "exitCode=%errorlevel%" & del "%tempFile%" >nul 2>nul
endlocal & exit /b %exitCode%