Solved

Merging or Copying data using Xcopy or Robocopy

Posted on 2006-07-08
7
5,559 Views
Last Modified: 2009-05-15
I need to copy/merge data from c:\ to d:\ however it is possible that their are duplicate files, what are the switches i need to use to make sure that the copy program only keeps/copies the newer version of the file?
0
Comment
Question by:itmstech
  • 3
7 Comments
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17066136
As long as the filenames are the same xcopy /d copies only newer files.  I tend to runit with

xcopy /d/e/h/r/k/o/y

which copies newer files in subdirectories (inc empty), hidden files, overwrites read only files, copies attibutes, acl & ownership and doesn't prompt to overwrite.

Robocopy with /MIR amongst other options will synchronise the dest from source (inc. deleting files that have been deleted from source which xcopy can't do).

Again I use:

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

SET logfile=c:\backups\logs\backup.log
SET source=\\server\share
SET dest=C:\backups\server
SET filespec=*.zip
SET options=/MIR /R:2 /W:10 /TEE /LOG+:%LOGFILE% /NP /NJH

robocopy %source% %destination% %filespec% %options%

hth

Steve
0
 

Author Comment

by:itmstech
ID: 17066761
Ok, I understand the commands and switches as I have been researching them and also testing. However, I have a slight problem. The files that exist in my destination directory are from a restore I did today which means that most if not everything has today's date there fore the /d:07-04-2006 switch I want to use with Xcopy is showing me 0 files to move because everything in the source is technically older than what is in my destination because of the restore.

however, I ran the following command: xcopy c:\data d:\restore /c /f /d:07-04-2006 /e /k /r /o /x and it copied the 437 files that changed out of the 125,000 that existed in the source.  However it also created the entire folder structure again.  I am afraid that if i now xcopy the data from the restore folder to my d:\ that I will overwrite folders that have data with folders that have nothing in it.

How to merge then? Ugggggg
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17067136
OK so is your merge problem that files are missing from the source folder which you are trying to put back from a restored folder? in which case, xcopy all the files from C: ignoring the /D option and it will overwrite any files on D: but any additional files will of course remain.  Doing it with robocopy /MIR would of course delete them.

xcopy will never delete any file or overwrite a full directory with a blank one - it will always copy over the top.

For a one off you could always just use explorer to do the copy.

Can you clarify for me which directories are the problem, I.e.

a : incomplete
b : complete but restored version
etc.
0
 
LVL 9

Accepted Solution

by:
SamuraiCrow earned 500 total points
ID: 17067421
Here is the robocopy syntax:

robocopy "source" "destination" *.* /E /Copyall /R:1 /W:1 /IS

If you need to download it you can get it in the 2003 Resource Kit:

http://www.microsoft.com/downloads/details.aspx?FamilyID=9D467A69-57FF-4AE7-96EE-B18C4790CFFD&displaylang=en

I've been a big robocopy fan since the NT4 days.  This syntax won't overwrite newer copies and will maintain the NTFS permissions.

Hope this helps.

Crow
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 17282670
Or maybe at least a split :-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
NTFS file system has been developed by Microsoft that is widely used by Windows NT operating system and its advanced versions. It is the mostly used over FAT file system as it provides superior features like reliability, security, storage, efficienc…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

911 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

23 Experts available now in Live!

Get 1:1 Help Now