Link to home
Start Free TrialLog in
Avatar of ramble
rambleFlag for United States of America

asked on

xcopy command line parameters

Below are the xcopy command-line parameters:

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

XCOPY source [destination] [/A | /M] [/D[:date]] [/P] [/S [/E]] [/V] [/W]
                           [/C] [/I] [/Q] [/F] [/L] [/G] [/H] [/R] [/T] [/U]
                           [/K] [/N] [/O] [/X] [/Y] [/-Y] [/Z]
                           [/EXCLUDE:file1[+file2][+file3]...]

  source       Specifies the file(s) to copy.
  destination  Specifies the location and/or name of new files.
  /A           Copies only files with the archive attribute set,
               doesn't change the attribute.
  /M           Copies only files with the archive attribute set,
               turns off the archive attribute.
  /D:m-d-y     Copies files changed on or after the specified date.
               If no date is given, copies only those files whose
               source time is newer than the destination time.
  /EXCLUDE:file1[+file2][+file3]...
               Specifies a list of files containing strings.  Each string
               should be in a separate line in the files.  When any of the
               strings match any part of the absolute path of the file to be
               copied, that file will be excluded from being copied.  For
               example, specifying a string like \obj\ or .obj will exclude
               all files underneath the directory obj or all files with the
               .obj extension respectively.
  /P           Prompts you before creating each destination file.
  /S           Copies directories and subdirectories except empty ones.
  /E           Copies directories and subdirectories, including empty ones.
               Same as /S /E. May be used to modify /T.
  /V           Verifies each new file.
  /W           Prompts you to press a key before copying.
  /C           Continues copying even if errors occur.
  /I           If destination does not exist and copying more than one file,
               assumes that destination must be a directory.
  /Q           Does not display file names while copying.
  /F           Displays full source and destination file names while copying.
  /L           Displays files that would be copied.
  /G           Allows the copying of encrypted files to destination that does
               not support encryption.
  /H           Copies hidden and system files also.
  /R           Overwrites read-only files.
  /T           Creates directory structure, but does not copy files. Does not
               include empty directories or subdirectories. /T /E includes
               empty directories and subdirectories.
  /U           Copies only files that already exist in destination.
  /K           Copies attributes. Normal Xcopy will reset read-only attributes.
  /N           Copies using the generated short names.
  /O           Copies file ownership and ACL information.
  /X           Copies file audit settings (implies /O).
  /Y           Suppresses prompting to confirm you want to overwrite an
               existing destination file.
  /-Y          Causes prompting to confirm you want to overwrite an
               existing destination file.
  /Z           Copies networked files in restartable mode.

The switch /Y may be preset in the COPYCMD environment variable.
This may be overridden with /-Y on the command line.

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Lets say that I backup

c:\dir1   to   d:\backup\dir1

I use, practically all of the command-line args...so I do a recursive, all sub directories...etc.

I DO THIS EVERY DAY

Now, lets say that I DELETE c:\dir1\myfiles\documents\not_important.doc

When the xcopy runs, I want the destination (d:\backup\dir1\myfiles\documents\not_important.doc) to be removed...since it no longer exists in the source.

Do I need to write another program (or find another program) to do this?  What do ya'll suggest?

If there is a free program out there that does this, it needs to also copy over the permissions (ACLs etc.).  But I haven't found one.

Thanks IA for any info.



SOLUTION
Avatar of peter_fleur
peter_fleur
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ramble

ASKER


This looks like it will work.  I'll work on it today.  robocopy has a command line parameter:
            /PURGE : delete dest files/folders that no longer exist in source.
That appears to be what I'm looking for.

Although it's labeled for 2003 Server, I'm guessing that it will work on 2000
It will work on a Windows 2000 machine. They upgraded the resource kits but the tools are all the same except for some new extra 2003 files. You can also use the /mirror line parameter. I don't really know the difference now but it's described in the /?

Peter
Avatar of bbao
quoted from RK's documenation: RoboCopy is a 32-bit Windows command-line application that simplifies the task of maintaining an identical copy of a folder TREE in multiple locations, either on the same computer or in separate network locations. RoboCopy can provide time-efficient maintenance of mirror images of large folder trees on network servers separated by slow or unreliable wide area networks (WANs) links.

RoboCopy can maintain directory TREE, not their content, so i dont think it is what ramble needs.

ramble, it sounds that you need a full content synchronization of folder(s)?
Avatar of ramble

ASKER


Well, I'm going to experiment with it a little.  Initially, it sure looks to me that it does everything xcopy does...but more.  bbao: what makes you think it doesn't maintain their content as well?

http://www.ss64.com/nt/robocopy.html

bbao: you are correct, I'm wanting full content synchronziation as well.  


Avatar of ramble

ASKER


Hey...on that link I posted above...down below called "related links", it looks like scopy might be good.  Sure seems simple to use.  Do you guys have any experience with scopy?

In my experience robocopy does copy content too. It keep the NTFS security too so not only the tree but also the files in it. And you can make a mirror with the /MIR command line function.

Peter
scopy is retired, replaced by new version of xcopy of windows 2000.
peter_fleur, yes, robocopy does copy content too, as well as other *copy utilities do. but what ramble needs is  "full content synchronization of folder(s)", please read above posts.
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of notch_ur_head
notch_ur_head

hahaha,

then what is the need for the backup if it also deletes the file when it is deleted from the source??

-notch_ur_head
yes, it does!
Avatar of ramble

ASKER


notch_ur_head: That's actually what I'm looking for.  Without it, then the the files in the backup (or the overall backup set) would become bloated with time...full of old temporary files that nobody wants anymore.

I have 20 120GB harddrive (firewire & USB 2.0)...so I propagate the backups down the line...eg. D=>E, E=>F,F=G... Then I run a weekly tape backup for archival purposes.

But, thanks to all,  I have plenty of backup info.  I'll probably use robocopy or xxcopy:

robocopy and xxcopy comparison: http://www.xxcopy.com/xxcopy30.htm

bbao: I'm still not sure, maybe I'm being dense, why you don't think robocopy (or xxcopy for that matter) wouldn't work???  It seems to be relatively robust, and the /PURGE or /MIR option appears to do exactly what your script is doing.

Do you mind expanding on that?
ramble, just had a try robocopy 1.96 on my machine, yes! it does what my batch does and even better and more. i am wondering why my robocopy /? only shows /mir option, so i did think robocopy does not support those options. in fact, i did not know robocopy before, and nice to learn about such a power tool. anyway, my batch is not bad too, especially when you work on old systems or those without RK installed, hehe ;-)
Avatar of ramble

ASKER


Thanks All!
Avatar of ramble

ASKER

Thanks_ramble

Just Ignore the last comment