Tuesday, January 4, 2011

Robocopy and Delete

@echo on
setlocal
set TODAY=%year%-%month%-%day% //create a variable called TODAY for the date
set LOGFILE=c:\sqlBackup-%TODAY%.log //set log file location
Set SOURCE=\\nas\backups\prod //set source of files to be copied
Set Target=\\nas\backups\prod2 //set destination of files to be copied
cd "Program Files\Windows Resource Kits\Tools" //navigate to location of robocopy executable
robocopy.exe %SOURCE% %TARGET% /MIR //execute robocopy with variables
echo Y|del %SOURCE%\*.* //delete all files from source
endlocal

No comments:

Post a Comment