Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I want to use XCOPY for an easy copy script to 'sync' one folder to another, every night.

XCOPY C:\hyper-v\VHD\*.avhd Z:\BACKUP\HYPERV_VMs /s /d /c

I cannot manage to get no prompting. When I choose the option /y xcopy overwrites everything (115GB) so no good. I don't see another option to disable the prompting and NOT overwrite existing files.

(If you have a proposition to use another command, be my guest, maybe adjust the existing example then)

Thanks in advance!

share|improve this question
    
Windows IS illogical, and is keen of prompting for every minor change. There was even a joke: "Windows 95 has detected the mouse changing its position. Reboot now?" :) robocopy is a more advanced tool, for sure - it's the thing you need ;) –  kolypto Nov 11 '09 at 20:31

6 Answers 6

up vote 6 down vote accepted

Robocopy has far more options and is built in on most recent Windows versions.

robocopy source-dir destination-dir filespec /E /XC /XN /XO

This will only copy across files that meet filespec (e.g. *.avhd in your example) from source dir (c:\Hyper-V\vhd in your example) to destdir (z:\backup\hyperv_vms). The switches tell it to skip older, newer and changed files so it will only copy across files that exist in the source directory that do not exist in the destination already.

share|improve this answer
    
Thanks for your answers. This one worked like a charm, fast, very informative and exactly what I need. Obviously robocopy is integrated in Win2008 (R2) Thanks again! the command I used: robocopy C:\hyper-v\VHD Z:\BACKUP\HYPERV_VMs *.avhd /E /XC /XN /XO –  laurens Nov 10 '09 at 13:47

I use xcopy /d /e /c /k /y /v /o which provides no prompting and doesn't overwrite existing files if the source is the same date as the destination.

share|improve this answer

The /M parameter tells it to copy only files with the "Archive" attribute set, and resets that attribute at the same time.

The "archive" bit is a part of the file system, like the "Read Only" bit or the "System file" bit. It was traditionally used for old-fashioned "naive" backup software so that it could tell whether or not a file had been changed since it had been archived last. The OS should switch on the archive bit any time a file is changed (or set it on newly created files) and the backup software then backs up the file and switches the bit off to show that it has been archived now.

You can see whether or not this is set on your files by changing to the folder in a command prompt and running attrib any files with an "A" in the first column are waiting to be archived.

share|improve this answer

I would use rsync for this purpose. You can download a Windows-compatible binary or get it as part of Cygwin (I recommend the former approach unless you already have Cygwin installed). You can either push files to the remote site or pull from it. I prefer the pull method, but either will do.

Using the pull method, the rsync daemon will run on the source server; using push, the rsync daemon will run on the destination server. Here's an example of a pull daemon config file:

max connections = 4
port           = 873
read only      = true
write only     = false
auth users     = syncman
secrets file   = /etc/rsyncd.secrets
strict modes   = false
hosts allow    = 192.168.1.8
refuse options = delete

[ProjectOne]
comment = Jimmy's Project
path    = C:/projects/project_one

[MutualProject]
comment = The MUTUAL project
path    = C:/paid_projects/mutual

How you specify the path will depend on which rsync port you use (e.g. cygwin specifies paths like this: /cygdrive/c/projects/project_one). You would then issue this command from the server:

rsync -a -v 192.168.1.15:ProjectOne backups/ProjectOne

(where the IP address is the source machine's IP address). If the backup server is a Windows box, you would need one of the many cron-for-windows implementations.

share|improve this answer
    
Thank you, this could come in handy another time. Here, I already had my mapped network drives and it can't be easier then with Robocopy –  laurens Nov 10 '09 at 13:50

If you need to roll your own incremental backup, I would suggest finding a version of rsync that works with Windows, or install Cygwin with the rsync port. It's designed to do just that and has a lot more options than xcopy.

share|improve this answer

If I do

xcopy junk*.* \TEMP /s /d /c /y

it does nothing the second time I run it, so not sure why yours is re-copying the files each time?

I've seem same files on different servers having times which are "off by a small amount" - could that be the cause?

share|improve this answer
    
May be related to FAT timestamps having only 2-second resolution. –  grawity Nov 10 '09 at 15:35

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.