So I'm trying to copy a backup of the data from my app. I wrote the batch script below to do this, but the script takes forever to run.
I start the batch script at 1am, and it is still running at 8:30am. This seems weird to me because when I copy the backup of my app manually in Windows File Explorer, it copies in 7-15 minutes depending on network traffic.
I REM the %backupcmd% "C:\Program Files\App\App Server\Data\Backups" "%drive%\" line. That was the original line of batch script I used to backup the data, and it worked efficiently up till a month ago.
So I tried the xcopy command with /d, so it would only copy source files that have been changed on or after that date (the current date), and the backups I'm copying are made at 12:01am every night and the copy backup script starts at 1am.
Any advice as to how to speed up my xcopy would be appreciated. If you think I should use powershell for this task too, I'm open to that option as well.
@echo off
for /F "usebackq tokens=1,2 delims==" %%i in (`wmic os get LocalDateTime /VALUE 2^>NUL`) do if '.%%i.'=='.LocalDateTime.' set ldt=%%j
set yyyy=%ldt:~0,4%
set mm=%ldt:~4,2%
set dd=%ldt:~6,2%
:: variables
set drive=Z:\RootSoft\App\Data Backups
set backupcmd=xcopy /s /c /d /e /h /i /r /y /f /z
echo ### Backing up Backup...
REM %backupcmd% "C:\Program Files\App\App Server\Data\Backups" "%drive%\"
xcopy "C:\Program Files\App\App Server\Data\Backups" "Z:\RootSoft\App\Data Backups" /D:%mm%-%dd%-%yyyy% /s /c /e /h /i /r /y /f /z
:: use below syntax to backup other directories...
:: %backupcmd% "...source directory..." "%drive%\...destination dir..."
echo Backup Complete!
echo %errorlevel%
pause
2 Answers 2
You could try with ROBOCOPY and /MT switch which could accelerate the copy.
Also you can make some test by measuring the during process with TimeThis that can be found here (no need to be installed, just extract the exe with 7z in the current batch file folder)
5 Comments
netsh interface tcp show global
netsh int tcp set heuristics disabled
- netsh int tcp set global autotuninglevel=disabled
- netsh int ip set global taskoffload=disabled
/cmakesxcopyignore errors while copying.