• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1154
  • Last Modified:

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?
0
Erwin Krisch
Asked:
Erwin Krisch
  • 3
  • 3
  • 2
  • +1
2 Solutions
 
Steve KnightIT ConsultancyCommented:
Might be worth looking into ROBOCOPY instead.  Much more suitable for synchronisation type scripts and errors are handled nicely.

Steve
0
 
Steve KnightIT ConsultancyCommented:
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
0
 
SteveGTRCommented:
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:

http://www.experts-exchange.com/Operating_Systems/MSDOS/Q_21484284.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
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
SteveGTRCommented:
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:"
0
 
callrsCommented:
Easy fix: www.xxcopy.com

xxcopy c:\students\  c:\serverbackup\studback\ /clone

Will backup all files in the folder. No need to worry about all the switches -- just use /clone.

: )
0
 
Erwin KrischAuthor Commented:
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?
0
 
Steve KnightIT ConsultancyCommented:
See robocopy /MIR for the same really.  I just wrapped some error checking around it for you above.

Steve
0
 
Erwin KrischAuthor Commented:
Hello gragon-it,
Can you tell me what incremental backup means versus append?
0
 
callrsCommented:
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.
0
 
callrsCommented:
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"
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

  • 3
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now