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!
Robocopy has far more options and is built in on most recent Windows versions.
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.
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.
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.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:
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:
(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.
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.
If I do
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?