Wednesday, May 30, 2018

Batch file to create backups of files to remote network paths using date and time stamps

Robocopy example rem batch file to create backups of files to remote network paths using date and time stamps FOR /f "tokens=1-5 delims=/- " %%a in ('date /t') DO SET XDate=%%d%%b%%c FOR /f "tokens=1-5 delims=/- " %%a in ('date /t') DO SET XSDate=%%d%%b FOR /f "tokens=1-2 delims=: " %%a in ('time /t') DO SET XTime=%%a%%b Echo "%XSDate%\%XDate%\%XDate%_%XTime%" set PW=Somepass1@@ set USR=Install rem set SOUPATH=Internal set SOUPATH=Dev_Local rem set LAB=DSCLIVE set LAB=DSCLAB set ROLE=DC1 net use M: \\%Lab%%Role%\c$\%SOUPATH% %PW% /user:%usr% Robocopy C:\Dev_Local M:\Backup\Code_Backup\%Lab%_%XDate%_%XTime%\%Lab%%Role% *.* /S /Z /XF *.EXE *.MSI *.ISO net use m: /delete

No comments:

Post a Comment