Solved

Why does XCOPY /C switch not work?

Posted on 2006-06-22
10
1,129 Views
Last Modified: 2008-02-01
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
Comment
Question by:Erwin Krisch
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
  • 2
  • +1
10 Comments
 
LVL 43

Assisted Solution

by:Steve Knight
Steve Knight earned 250 total points
ID: 16960565
Might be worth looking into ROBOCOPY instead.  Much more suitable for synchronisation type scripts and errors are handled nicely.

Steve
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 16960620
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
 
LVL 30

Expert Comment

by:SteveGTR
ID: 16960742
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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 30

Expert Comment

by:SteveGTR
ID: 16960752
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
 
LVL 30

Accepted Solution

by:
callrs earned 250 total points
ID: 16964923
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
 

Author Comment

by:Erwin Krisch
ID: 16967951
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
 
LVL 43

Expert Comment

by:Steve Knight
ID: 16968014
See robocopy /MIR for the same really.  I just wrapped some error checking around it for you above.

Steve
0
 

Author Comment

by:Erwin Krisch
ID: 16968027
Hello gragon-it,
Can you tell me what incremental backup means versus append?
0
 
LVL 30

Expert Comment

by:callrs
ID: 16968037
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
 
LVL 30

Expert Comment

by:callrs
ID: 16968108
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Help with a batch file 13 83
IBM T20 - can DOS and Win95 be installed and fully working? 29 188
Command prompt output to variable? 9 73
Upgrade dos 4.00.1111 11 29
The following is a collection of cases for strange behaviour when using advanced techniques in DOS batch files. You should have some basic experience in batch "programming", as I'm assuming some knowledge and not further explain the basics. For some…
Being a system administrator some time we require to do things remotely, one of them is installing software. Here I am going to tell you how to install software through wmic (Windows management instrument console). I am not at all saying that this i…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question