Solved

Merging or Copying data using Xcopy or Robocopy

Posted on 2006-07-08
7
5,537 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Or maybe at least a split :-)
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Suggested Solutions

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…
This article will show you how to create an ISO CD-ROM/DVD-ROM image (*.iso), and MD5 checksum signature, for use with VMware vSphere Hypervisor 6.5 (ESXi 6.5). It's a good idea to compare checksums, because many installations fail because of a corr…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

772 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

11 Experts available now in Live!

Get 1:1 Help Now