Link to home
Start Free TrialLog in
Avatar of Erwin Krisch
Erwin KrischFlag for Canada

asked on

Why does XCOPY /C switch not work?

We use xcopy command to backup student files.
xcopy c:\students\*.* c:\serverbackup\studback\
/E/Y/C/I/F/R/K.

However, it stops after copying certain number
folders.
Switch /c doesn't work. Does anybody know why is this happening and how to fix this?
SOLUTION
Avatar of Steve Knight
Steve Knight
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Here's a wrapper for robocopy I use (slightly amended to remove specific paths):
You can download ROBOCOPY from the MS site.

@echo off
REM ----------------------------------------------------------------------------
REM Script to take copy of from source to dest
REM Uses resource kit ROBOCOPY
REM
REM Steve Knight.  2-Feb-2006
REM ----------------------------------------------------------------------------

REM ROBOCOPY Options are:
REM =====================
REM /MIR - copy all files and subdirectories and remove files from dest. not in source
REM /R:1 - 1 retry for failed copies
REM /W:5 - Wait time 5 seconds between retries
REM /TEE - write output to log file and screen
REM /LOG+: - append output to filename
REM /NP - No Progress percentage as this messes up log file
REM /NJH - No Job header in log file

set TODAYDATE=%date:~7,2%-%date:~4,2%-%date:~10,4%
if "%date:~2,1%"=="/" set TODAYDATE=%date:~3,2%-%date:~0,2%-%date:~6,4%

SET logfile=c:\backups\logs\germ-%todaydate%.log
SET source=c:\students
SET dest=C:\serverbackup\studback
SET filespec=*.*
SET options=/MIR /R:2 /W:10 /TEE /LOG+:%LOGFILE% /NP /NJH

SET ErrorPC=192.168.1.100
SET Erroruser=ausername

echo Copying files from %source% to %dest%

echo %DATE% %TIME% - Started copy of backup files  >> %LOGFILE%
ROBOCOPY "%source%" "%dest%" %filespec% %options%

REM Errorlevel 1 = Sucessful copy, 2 is extra filed needed deleting, 3 = both
REM so Errorlevel 4 is another error
if errorlevel 4 goto error
if errorlevel 3 goto OKCopyAndDel
if errorlevel 2 goto OKDelete
if errorlevel 1 goto OKCopy
if errorlevel 0 goto OKNothing

:OKCopyAndDel
  net send %ErrorPC% "%DATE% %TIME% Copy OK - Copied & Deleted"
  echo %DATE% %TIME% - Backup Operation Successful >> %LOGFILE%

goto end

:OKDelete
  net send %ErrorPC% "%DATE% %TIME% Copy OK - Deleted Only"
  echo %DATE% %TIME% - Backup Operation Successful >> %LOGFILE%

goto end

:OKCopy
  net send %ErrorPC% "%DATE% %TIME% Copy OK - Copied only"
  echo %DATE% %TIME% - Backup Operation Successful >> %LOGFILE%

goto end

:OKNothing
  net send %ErrorPC% "%DATE% %TIME% Copy OK - Nothing to do"
  echo %DATE% %TIME% - Backup Operation Successful >> %LOGFILE%

goto end

:error
  echo %DATE% %TIME% - Backup Operation Failed >> %LOGFILE%
  net send %ErrorPC% "%DATE% %TIME% Copy has reported an error"
  net send %ErrorUser% "%DATE% %TIME% Copy has reported an error"
goto end

:end
Any error messages issues? I've seen where XCOPY will run out of memory. Apparently you can example the ERRORLEVEL to determine what the problem is. Here's a link to an EE question that goes into that:

https://www.experts-exchange.com/questions/21484284/Error-level-reporting-not-working-in-this-batch-job.html

As for fixing the problem. You could use ROBOCOPY (like Dragon-it suggests) or write a complicated batch file to perform the processing.

Good Luck,
Steve
This:

"Apparently you can example the ERRORLEVEL to determine what the problem is. Here's a link to an EE question that goes into that:"

Should read:

"Apparently you can examine the ERRORLEVEL to determine what the problem is. Here's a link to an EE question that goes into that:"
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Erwin Krisch

ASKER

Hello callrs,

xxcopy what a great program. Just one more question, when it says incremental does it mean that everytime it clones a directory it ads to the previous cloning the new files and leaves the old ones intact, or will it just replace one cloned directory with a new one?
See robocopy /MIR for the same really.  I just wrapped some error checking around it for you above.

Steve
Hello gragon-it,
Can you tell me what incremental backup means versus append?
Avatar of callrs
callrs

Let me know where it says that...

But if you are asking about the /clone option:
Clone makes an exact copy.
So
xxcopy c:\ d:\cbackup\ /clone

Will copy the entire c:\ drive to the cbackup folder of d: drive

Any files in cbackup that are not in c: will get deleted.  ONLY files THAT WERE CHANGED SINCE THE LAST COPY DATE  will get copied. So updates are fast once you've made the first clone.


>>that every time it clones a directory it ads to the previous cloning the new files and leaves the old ones intact
old files that are also in the folder being copied from remain intact. If you delete some files from the copy-from location, then /clone deletes those files from the copy-to location.

>or will it just replace one cloned directory with a new one?
No, it just writes changed files. So updates are fast after you make the first clone.
Backup Types:

Full              - copy everything.
Differential   - copy everything since the last Full.
Incremental  - copy the changes since the last differential or full.

More info on backups: http://www.lwcomputing.com/tips/static/backup.asp  " LWComputing.com - Backup Recommendations"