Solved

Why does XCOPY /C switch not work?

Posted on 2006-06-22
10
1,114 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
  • 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

YESTERDAY YESTERDAY.BAT is inspired by a previous article I wrote entitled: TOMORROW.BAT (http://www.experts-exchange.com/OS/Microsoft_Operating_Systems/MS_DOS/A_4196-Advanced-Batch-File-Programming-TOMORROW-BAT.html). The crux of this batch f…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now