?
Solved

Why does XCOPY /C switch not work?

Posted on 2006-06-22
10
Medium Priority
?
1,141 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 1000 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
Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

 
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 1000 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Using dates in 'DOS' batch files has always been tricky as it has no built in ways of extracting date information.  There are many tricks using string manipulation to pull out parts of the %date% variable or output of the date /t command but these r…
VALIDATING DATES One method of validating dates is to jam the date into the DATE command and see if it accepts it by examining the system's errorlevel value. A non-zero result indicates failure. A typical example might look something like the fol…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

801 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