Robocopy backup/archive data

Robocopy backup/archive data – User can run. We could copy below code to a runRoboCopy.cmd

@echo off
setlocal
@Rem -->***CHANGME
set dataSource=D:
set backupDestination=D:\BACKUP
@Rem <--CHANGME***

set scriptPath=c:\roboCopy
set logPath=c:\roboCopy\log
set dateStamp=%DATE:~-4%-%DATE:~4,2%-%DATE:~7,2%

if NOT EXIST C:\roboCopy\NUL goto CREATEDIR

goto STARTBATCHNOW
 
:CREATEDIR
mkdir C:\roboCopy
mkdir C:\roboCopy\log
mkdir %dataSource%\TESTME
mkdir %backupDestination%
mkdir %backupDestination%\Archiver
:STARTBATCHNOW
@REM *** START: Turns logging on ***
if "%~1" == "NOWLOGGING" goto NOWLOGGING
 set SchedulesLogFile=%logPath%\%~n0-%dateStamp%.txt
 %0 "NOWLOGGING" > "%SchedulesLogFile%" 2>&1
 rem goto :EOF
:NOWLOGGING
@REM *** END: Turns logging on ***
@rem Guts of batch file...

echo [%date% %time%] starting... 
echo *** start of actual batch file...
@REM Copy data to USB hdd for Backup

robocopy "%dataSource%\TESTME" "%backupDestination%\TESTME" /E /COPY:DAT /R:3 /W:6 /NDL /NP /LOG:"%logPath%\log.copy-DATA.txt"


@rem NOTE:****Add/Remove Option [/L] to make a test/run robocopy 
@rem NOTE:****Add Option [/TEE] to make a run robocopy show console log
@REM Move files older than 60 days to USB hdd for archiver
rem mkdir %backupDestination%\Archiver\
rem robocopy %dataSource%\Data %backupDestination%\Archiver\ /L /MOV /MINAGE:60 /E /COPY:DAT /NDL /NP /R:3 /W:6 /LOG:"%logPath%\log.Archive60daysOldFiles.txt"

:EOF
echo *** end of batch file...
echo [%date% %time%] ending... 
endlocal



Robocopy backup/archive data – User with administrator can run to backup NTFS alc permission

@echo off
setlocal
@Rem -->***CHANGME
set dataSource=D:
set backupDestination=D:\BACKUP
@Rem <--CHANGME***

set scriptPath=c:\roboCopy
set logPath=c:\roboCopy\log
set dateStamp=%DATE:~-4%-%DATE:~4,2%-%DATE:~7,2%

if NOT EXIST C:\roboCopy\NUL goto CREATEDIR

goto STARTBATCHNOW
 
:CREATEDIR
mkdir C:\roboCopy
mkdir C:\roboCopy\log
@Rem -->***CHANGME Test
mkdir %dataSource%\TESTME
@Rem <--CHANGME Test***
mkdir %backupDestination%
mkdir %backupDestination%\Archiver

:STARTBATCHNOW
@REM *** START: Turns logging on ***
if "%~1" == "NOWLOGGING" goto NOWLOGGING
 set SchedulesLogFile=%logPath%\%~n0-%dateStamp%.txt
 %0 "NOWLOGGING" > "%SchedulesLogFile%" 2>&1
 rem goto :EOF
:NOWLOGGING
@REM *** END: Turns logging on ***
@rem Guts of batch file...

echo [%date% %time%] starting... 
echo *** start of actual batch file...
@REM Copy data to USB hdd for Backup

robocopy "%dataSource%\TESTME" "%backupDestination%\TESTME" /S /E /COPYALL /R:3 /W:6 /NDL /NP /LOG:"%logPath%\log.copy-TESTME.txt"


@rem NOTE:****Add/Remove Option [/L] to make a test/run robocopy 
@rem NOTE:****Add Option [/TEE] to make a run robocopy show console log
@REM Move files older than 60 days to USB hdd for archiver
rem mkdir %backupDestination%\Archiver\
rem robocopy %dataSource%\Data %backupDestination%\Archiver\ /L /MOV /MINAGE:60 /E /COPY:DAT /NDL /NP /R:3 /W:6 /LOG:"%logPath%\log.Archive60daysOldFiles.txt"

:EOF
echo *** end of batch file...
echo [%date% %time%] ending... 
endlocal