As part of the annual EPM DR Rehearsal, we got a requirement to move Prod Application backup files from PROD Network location to DR network path.
In this post, we will see how we can RoboCopy EPM backup files from one Network location to another network path.
Why ROBOCOPY?
If you are copying files from one network path to another and you have Windows Vista or later operating systems then Robocopy is a better choice than any other option. Because you don't need to bother with drive mappings, since it handles UNC paths just fine.
Robocopy is not a third party software. It's native (built-in) to all versions of Windows Vista and later.
It is usually far more reliable than xcopy command, and provides a lot more options.
Robocopy is tolerant of interrupts during copying i.e. it can pick up where it left off if it gets stopped for some reason. It has the ability to recover from certain types of network hiccups automatically.
Read Link1 and Link2 for more details about ROBOCOPY and its various options.
Script using ROBOCOPY to copy EPM backups from PROD to DR network path:
@echo off
for /f "delims=" %%a in ('wmic OS Get localdatetime ^| find "."') do set "dt=%%a"
::Format the WMIC command output in DDMMYYYY format
set "YY=%dt:~0,4%"
set "MM=%dt:~4,2%"
set "DD=%dt:~6,2%"
set "today_date=%DD%%MM%%YY%"
::Define Source path
set sourcepath1=\\PROD_Network_Share\data\EPM_Backups\%today_date%
set sourcepath2=\\PROD_Network_Share\data\EPM_Backups\DataZip
set sourcepath3=\\PROD_Network_Share\data\EPM_Backups\Scripts
::Define Destination path
set destinationpath1=\\DR_Network_Share\data\EPM_Backups_Copy\%today_date%
set destinationpath2=\\DR_Network_Share\data\EPM_Backups_Copy\DataZipCopy
set destinationpath3=\\DR_Network_Share\data\EPM_Backups_Copy\ScriptsCopy\%today_date%
::Define Log path
set logfile=E:\Admin\Prod_To_DR_Copy.log
::Run RoboCopy commands
REM Copy all the files, folders and sub-folders from source to destination
robocopy %sourcepath1% %destinationpath1% /E /COPY:DAT /NP /LOG+:"%logfile%"
REM Copy today'sdate(DDMMYY).zip file from source to destination
robocopy %sourcepath2% %destinationpath2% %today_date%.zip /COPY:DAT /NP /LOG+:"%logfile%"
REM Copy all the files with extensions .sh, .mxl, .ksh, .scr from source to destination
robocopy %sourcepath3% %destinationpath3% *.sh *.mxl *.ksh *.scr /COPY:DAT /NP /LOG+:"%logfile%"
- /E = Copy files including subfolders (even empty ones)
- /COPY:copyflag[s] = what to COPY for files. Here we have selected DAT: D=Data, A=Attributes, T=Timestamps
- /NP = No Progress - don’t display % copied text in logfile; this keeps filesize down.
- /LOG+:logfile = Output status to LOG file (+= append to existing log).