Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @ECHO OFF
- SETLOCAL
- :Input
- SET /P "source=Please enter or paste the location you want backed up and press ^<Enter^>."
- IF "%source%"=="" GOTO Error
- GOTO :DoTask
- :Error
- ECHO You did not specify a location to be backed up! Please try again. & goto :Input
- ::SET source="":: Obsolete for now, since user input is possible.
- :DoTask
- REM SET YEAR
- set YEAR=%date:~6,4%
- REM SET MONTH
- set MONTH=%date:~3,2%
- if %MONTH% LSS 10 set MONTH=%MONTH:~1,2%
- if %MONTH% LSS 10 set MONTH=0%MONTH%
- REM SET DAY
- set DAY=%date:~0,2%
- if %DAY% LSS 10 set DAY=%DAY:~1,2%
- if %DAY% LSS 10 set DAY=0%DAY%
- REM SET HOUR
- set HOUR=%time:~0,2%
- if %HOUR% LSS 10 set HOUR=%HOUR:~1,2%
- if %HOUR% LSS 10 set HOUR=0%HOUR%
- REM SET MINUTE
- set MINUTE=%time:~3,2%
- if %MINUTE% LSS 10 set MINUTE=%MINUTE:~1,2%
- if %MINUTE% LSS 10 set MINUTE=0%MINUTE%
- REM SET SECOND
- set SECOND=%time:~6,2%
- if %SECOND% LSS 10 set SECOND=%SECOND:~1,2%
- if %SECOND% LSS 10 set SECOND=0%SECOND%
- SET destination="Backups"\%date%
- SET logdir="Backups\Logs"\%date%
- SET log="Backups\Logs"\%date%\%HOUR%_%MINUTE%_%SECOND%.log
- mkdir "%logdir%" 2>NUL
- SET copyoptions=/COPYALL /E /ZB /SEC /MIR
- :: /COPYALL :: COPY ALL file info.
- :: /E :: Copy Subfolders, including Empty Subfolders.
- :: /ZB :: Use restartable mode; if access denied use Backup mode.
- :: /SEC :: Copy files with SECurity.
- :: /MIR :: MIRror a directory tree.
- SET logoptions=/R:0 /W:0 /LOG:%log% /TS /NP /V /ETA /TIMFIX /SECFIX /TEE
- :: /R:n:: Number of Retries.
- :: /W:n:: Wait time between retries.
- :: /LOG:: Output log file.
- :: /TS :: Include Source file Time Stamps in the output.
- :: /NP :: No Progress - don’t display % copied.
- :: /V :: Produce Verbose output log, showing skipped files.
- :: /ETA:: Show Estimated Time of Arrival of copied files.
- :: /TIMFIX :: FIX file TIMes on all files, even skipped files.
- :: /SECFIX :: FIX file SECurity on all files, even skipped files.
- :: /TEE:: Output to console window, as well as the log file.
- :: /NFL:: No file logging.
- :: /NDL:: No dir logging.
- ROBOCOPY %source% %destination% %copyoptions% %logoptions%
- :End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement