Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2013
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.09 KB | None | 0 0
  1. @ECHO OFF
  2. SETLOCAL
  3.  
  4. :Input
  5. SET /P "source=Please enter or paste the location you want backed up and press ^<Enter^>."
  6. IF "%source%"=="" GOTO Error
  7. GOTO :DoTask
  8. :Error
  9. ECHO You did not specify a location to be backed up! Please try again. & goto :Input
  10.  
  11. ::SET source="":: Obsolete for now, since user input is possible.
  12.  
  13. :DoTask
  14. REM SET YEAR
  15. set YEAR=%date:~6,4%
  16.  
  17. REM SET MONTH
  18. set MONTH=%date:~3,2%
  19. if %MONTH% LSS 10 set MONTH=%MONTH:~1,2%
  20. if %MONTH% LSS 10 set MONTH=0%MONTH%
  21.  
  22. REM SET DAY
  23. set DAY=%date:~0,2%
  24. if %DAY% LSS 10 set DAY=%DAY:~1,2%
  25. if %DAY% LSS 10 set DAY=0%DAY%
  26.  
  27. REM SET HOUR
  28. set HOUR=%time:~0,2%
  29. if %HOUR% LSS 10 set HOUR=%HOUR:~1,2%
  30. if %HOUR% LSS 10 set HOUR=0%HOUR%
  31.  
  32. REM SET MINUTE
  33. set MINUTE=%time:~3,2%
  34. if %MINUTE% LSS 10 set MINUTE=%MINUTE:~1,2%
  35. if %MINUTE% LSS 10 set MINUTE=0%MINUTE%
  36.  
  37. REM SET SECOND
  38. set SECOND=%time:~6,2%
  39. if %SECOND% LSS 10 set SECOND=%SECOND:~1,2%
  40. if %SECOND% LSS 10 set SECOND=0%SECOND%
  41.  
  42. SET destination="Backups"\%date%
  43. SET logdir="Backups\Logs"\%date%
  44. SET log="Backups\Logs"\%date%\%HOUR%_%MINUTE%_%SECOND%.log
  45.  
  46. mkdir "%logdir%" 2>NUL
  47.  
  48. SET copyoptions=/COPYALL /E /ZB /SEC /MIR
  49. :: /COPYALL :: COPY ALL file info.
  50. :: /E :: Copy Subfolders, including Empty Subfolders.
  51. :: /ZB :: Use restartable mode; if access denied use Backup mode.
  52. :: /SEC :: Copy files with SECurity.
  53. :: /MIR :: MIRror a directory tree.
  54.  
  55. SET logoptions=/R:0 /W:0 /LOG:%log% /TS /NP /V /ETA /TIMFIX /SECFIX /TEE
  56. :: /R:n:: Number of Retries.
  57. :: /W:n:: Wait time between retries.
  58. :: /LOG:: Output log file.
  59. :: /TS :: Include Source file Time Stamps in the output.
  60. :: /NP :: No Progress - don’t display % copied.
  61. :: /V :: Produce Verbose output log, showing skipped files.
  62. :: /ETA:: Show Estimated Time of Arrival of copied files.
  63. :: /TIMFIX :: FIX file TIMes on all files, even skipped files.
  64. :: /SECFIX :: FIX file SECurity on all files, even skipped files.
  65. :: /TEE:: Output to console window, as well as the log file.
  66. :: /NFL:: No file logging.
  67. :: /NDL:: No dir logging.
  68.  
  69. ROBOCOPY %source% %destination% %copyoptions% %logoptions%
  70.  
  71. :End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement