Scheduled backup robocopy with datestamp

@echo off
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"

set "datestamp=%YYYY%%MM%%DD%"
robocopy C:\dest C:\target\%datestamp% /S /E /Z /ZB /R:5 /W:5 /TBD /NP /V /MT:16

Leave a Reply

Your email address will not be published. Required fields are marked *