@echo off
rem Dependacies (tools need to be in the path variable): 7za.exe, HoboCopy.exe
set backupdir=C:
set backuplist=backup_list.txt
for /f "tokens=1,2,3,4 delims=/ " %%a in ("%date%") do set day=%%a&set month=%%b&set year=%%c
mkdir "%backupdir%\%year%-%month%-%day%"
mkdir "%temp%\%year%-%month%-%day%"
set logfile="%backupdir%\%year%-%month%-%day%\%year%-%month%-%day%.log"
set archive="%backupdir%\%year%-%month%-%day%\%year%-%month%-%day%.7z"
for /f "tokens=1-2 delims=," %%a in ('type "%backuplist%"') do hobocopy /r /y "%%a" "%temp%\%year%-%month%-%day%\%%b"
7za a -t7z "%archive%" "%temp%\%year%-%month%-%day%">>"%logfile%"
rd /s /q "%temp%\%year%-%month%-%day%"
@ECHO OFF
CLS
GOTO skipcomment
REM its been awhile since i wrote VB or BAT files
REM automate.vbs calls this file (i read it was a good way to have the backup run silently )
REM %1 is the dir tree (e: or c: or whatever)
REM %2 is the site name (Also the root folder in the dir tree)
REM %3 is the path to repozo (shouldnt change...)
REM %4 is the backup path for the backup
:skipcomment
REM Note:these are TEMP var's, there contents change often
SET folder=%date:~10,4%-%date:~4,2%-%date:~7,2%
SET return=empty
SET mkfolder=%4\%folder%\
SET /a count=0
SET logFolder=%4\log\%folder%.log
REM if testing is set to true, skip commands i know that are working.
SET testing=False
SET debugLine2=I-------------------------------------------------------------------------------------------------------------------I
SET debugLine3=I-------------------------------------------------------------------------------------------------------------------I
SET debugLine4=I-------------------------------------------------------------------------------------------------------------------I
SET debugEmpty=I-------------------------------------------------------------------------------------------------------------------I
SET debugEnd=L-------------------------------------------------------------------------------------------------------------------J
REM check Root folder
IF NOT EXIST %4 MKDIR %4
IF NOT EXIST %4\log\ MKDIR %4\log\
REM Log data passed by the VB script (automate.vbs)
GOTO logParams
:logParamsEnd
SET debugLine2= Running in Verbose mode
SET debug=debug1
GOTO debug
:debug1
SET return=roboFolderLog
SET folder=%4\roboBackup
GOTO doesFolderExists
:roboFolderLog
SET return=roboFolder
SET folder=%4\roboBackup\data
GOTO doesFolderExists
:roboFolder
REM .this Script location
SET scriptDir=%CD%
REM DEBUG
SET debugLine2="Call repozo with B backup, v verbose, z compressed, --r Backup Location, --f File Location"
SET debugLine3= "%1%2%3 -Bvz -r %4 -f %1%2\var\filestorage\Data.fs"
SET debug=debug2
GOTO debug
:debug2
REM DEBUG END
REM LOG
ECHO. >>%logFolder%
ECHO.REM call repozo (B = backup, v=verbose, z=compressed, -r=Backup Location, -f=File Location)>>%logFolder%
ECHO.%Time% Start: %1%2%3 -Bvz -r %4 -f %1%2\var\filestorage\Data.fs >>%logFolder%
IF %testing%== False %1%2%3 -Bvz -r %4 -f %1%2\var\filestorage\Data.fs >>%logFolder%
REM LOG
ECHO.%Time% End: %1%2%3 -Bvz -r %4 -f %1%2\var\filestorage\Data.fs >>%logFolder%
ECHO. >>%logFolder%
REM LOG
ECHO.%Time% : Current directory changed from %CD% to %4 >>%logFolder%
REM Backup folder
CD %4
REM DEBUG
SET debugLine2= Creating directory if not exists
SET debugLine3= %mkfolder%
SET debug=debug3
GOTO debug
:debug3
REM DEBUG END
SET roboLogName=ROBOCopy%date:~10,2%%date:~4,2%%date:~7,2%
IF NOT %testing%== False GOTO skip
REM Copyall=Copy all file info(users
REM E= copy files and folders(empty ones too)
REM R= retry 3 times if copy fails
REM w= wait 20sec before trying again or moving on
REM dcopy= keep origonal timestamp
REM v= show data (verbose)
REM np= No Progress bar
REM log= output data to the log file
REM XF= exclude file
REM m= only backup changed files.
REM DEBUG
SET debugLine2=Copy all Site files to the backup location
SET debugLine3="ROBOCOPY %1%2 %4\roboBackup\data /E /R:3 /W:20 /DCOPY:T /XF Data.fs /A /V /NP /LOG:%4\log\%roboLogName%.log"
SET debugLine4="Log file located at : %4\log\%roboLogName%.log"
SET debug=debug4
GOTO debug
:debug4
REM DEBUG END
IF %5 == False GOTO quickpass
ROBOCOPY %1%2 %4\roboBackup\data /E /R:3 /W:20 /DCOPY:T /XF Data.fs /A /V /NP /LOG:%4\log\%roboLogName%.log
GOTO skip
:quickpass
ROBOCOPY %1%2 %4\roboBackup\data /E /R:1 /W:0 /DCOPY:T /V /XF Data.fs /A /NP /LOG:%4\log\%roboLogName%.log
:skip
REM DEBUG
ECHO.%Time% : Done! >>%logFolder%
SET debugLine2= All Done!
SET debug=debug6
GOTO debug
:debug6
REM DEBUG END
REM LOG
ECHO.=================== >>%logFolder%
ECHO.^^^^^^^^^^^^^^ END ^^^^^^^^^^^^ >>%logFolder%
ECHO. >>%logFolder%
ECHO. >>%logFolder%
ECHO. >>%logFolder%
ECHO. >>%logFolder%
GOTO end
REM ----------------------------------------------
REM J's fun_ctions
REM ----------------------------------------------
REM Check Folder exists
:doesFolderExists
IF NOT EXIST %folder% GOTO createFolder
GOTO %return%
REM ----------------------------------------------
REM CREATE FOLDER
:createFolder
MKDIR %folder% >>%logFolder%
ECHO.%Time% : Create this folder >>%logFolder%
ECHO.%Time% : %folder% >>%logFolder%
GOTO %return%
REM ----------------------------------------------
REM DEBUG
:debug
REM put this in the log file
REM VV VV VV VV VV VV VV VV VV VV
SET /a count=%count%+1
SET debugLine1=r----------------------------------------- NOTE: %count% At: %Time% -----------------------------------------------,
ECHO. >>%logFolder%
ECHO.I%debugLine1% >>%logFolder%
ECHO.I%debugLine2% >>%logFolder%
IF NOT %debugLine3% == %debugEmpty% ECHO.I%debugLine3% >>%logFolder%
IF NOT %debugLine4% == %debugEmpty% ECHO.I%debugLine4% >>%logFolder%
ECHO.%debugEnd% >>%logFolder%
ECHO. >>%logFolder%
ECHO. >>%logFolder%
REM VV VV VV VV VV VV VV VV VV VV VV VV VVV
REM DEBUG MODE: Put this on the screen VV
REM VV VV VV VV VV VV VV VV VV VV VV VV VVV
IF %5 == False (
CLS
ECHO.
ECHO.I%debugLine1%
ECHO.I%debugLine2%
IF NOT %debugLine3% == %debugEmpty% ECHO.I%debugLine3%
IF NOT %debugLine4% == %debugEmpty% ECHO.I%debugLine4%
ECHO.%debugEnd%
ECHO.
ECHO.
REM NOTE: This is the only pause in the script (or this script cant be automated)
PAUSE
)
REM ^ ^^ ^^ ^^^ ^^ ^^^ ^^ ^^^ ^^ ^^^ ^^ ^^^
REM ^^ ^^^ ^^ ^^^ ^^ ^^^ ^^ ^^^ ^^ ^^^ ^^ ^
REM ^ ^^ ^^ ^^^ ^^ ^^^ ^^ ^^^ ^^ ^^^ ^^ ^^^
REM clear data
SET debugLine4= %debugEmpty%
SET debugLine3= %debugEmpty%
SET debugLine2= %debugEmpty%
GOTO %debug%
REM ----------------------------------------------
REM GET OUT OF MY HEAD(er)!!!!
REM ----------------------------------------------
REM Note: Not a fucntion.
:logParams
ECHO. >>%logFolder%
ECHO.vvvvvv START vvvvvv >>%logFolder%
ECHO.=================== >>%logFolder%
ECHO.I VBS Params I >>%logFolder%
ECHO.=================== >>%logFolder%
ECHO.Ran on:%Date% >>%logFolder%
ECHO. At:%Time% >>%logFolder%
ECHO. >>%logFolder%
ECHO. Log file path : %mkfolder% >>%logFolder%
ECHO.Drive Letter / Location : %1 >>%logFolder%
ECHO. Site : %2 >>%logFolder%
ECHO. Path to REPOZE : %1%2%3 >>%logFolder%
ECHO. Backup Folder Path : %4 >>%logFolder%
ECHO.shhhhsshh!(run Quitely) : %5 >>%logFolder%
ECHO. >>%logFolder%
ECHO.=================== >>%logFolder%
ECHO. >>%logFolder%
ECHO. >>%logFolder%
GOTO logParamsEnd
REM ----------------------------------------------
REM end fun_ctions
REM ----------------------------------------------
:end
@echo off
@cls
::Tested on a local machine using Windows 7 x64 Home Premium
::Use the ping command to wait -n # seconds; change # for time to wait
::Basic code can be found in various places on the internet
::Modified by Rectifier 06-30-2012
::If you receive an error try running the batch file as an administrator
::Note that the event log has to be enabled to begin with or this is a fairly useless batch
::Make readable prompt
echo. & echo. & echo.
echo Clearing event logs...
::Clear event logs by searching for them using a for loop
@for /f %%i in ( 'wevtutil el' ) do wevtutil cl "%%i" >NUL 2>&1
::Clear event logs not found by the for loop
wevtutil.exe cl "Microsoft-Windows-Diagnosis-DPS/Operational"
wevtutil.exe cl "Microsoft-Windows-User Profile Service/Operational"
wevtutil.exe cl "Microsoft-Windows-Windows Defender/Operational"
wevtutil.exe cl "Microsoft-Windows-Windows Defender/WHC"
wevtutil.exe cl "Microsoft-Windows-Windows Firewall With Advanced Security/Firewall"
wevtutil.exe cl System
::Informing the batch is finished executing
echo. & echo.
echo Batch finished!
ping 127.0.0.1 -n 3 | find "Reply" > nul
DOS Batch ipconfig flushdns批处理文件,用于主机DNS更改,帮助用户解析新主机
@echo off
rem Set this to the hostname that you just updated the A record on
set hostchk=server.example.org
rem Set this to the new A record address
set correctip=127.127.127.127
nslookup %hostchk%|| goto errornons
rem this is tricky, look for two of the strings "Address"
nslookup -type=A %hostchk% 2>nul | find /c "Address" | find "2" > nul
if ErrorLevel 1 goto error
for /f "tokens=2" %%a in ('nslookup %hostchk%') do set curhostip=%%a
cls
Echo Your computer thinks %hostchk% goes to %curhostip%
if /i "%curhostip%"=="%correctip%" goto allgood
goto flush
:allgood
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo That's CORRECT, you're all set for the server transition!
echo When the server comes online, you'll be ready to go.
echo Make sure all your programs reference %hostchk% and not an IP.
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pause
exit
:error
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Echo For some reason, your computer cannot look up %hostchk%.
Echo Put help text here
Echo Be sure to tell us this error: can't resolve %hostchk%
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pause
exit
:errornons
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Echo Your computer doesn't have nslookup so this batch file won't work.
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pause
exit
:error2
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Echo For some reason, your computer or ISP still cannot find the right IP
Echo Put help text here
Echo Be sure to tell us this error: got wrong ip %curhostip%
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pause
exit
:flush
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
echo That's INCORRECT, it should be %correctip%, so lets flush the DNS cache
echo now and see if it will help.
ipconfig /flushdns
Echo After you press a key, we'll see if flushing the cache worked.
echo ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
pause
for /f "tokens=2" %%a in ('nslookup %hostchk%') do set curhostip=%%a
cls
if /i "%curhostip%"=="%correctip%" goto allgood
goto error2
REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REM
REM FILENAME : GETDIRS.BAT
REM
REM DESCRIPTION : GENERATE LIST OF FOLDERS RECURSIVELY IN A FILE "TOEMPTY.BAT"
REM
REM AUTHOR : Napoleon Arouldass S. http://neps.in
REM
REM DATE WRITTEN : Tuesday, August 21, 2007 10:37:25 PM
REM
REM COMMENTS/REMARKS : This is the first step
REM
REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
REM GET DIRECTORY LISTING OF WINDOWS FILE SYSTEM
DIR %1/AD/B/S | SORT /R > TOEMPTY.BAT
REM ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~