90

I am trying to deploy a website from my desktop to my webserver and so right now I am doing this:

 xcopy C:\source X:\destination /s

My desktop is a Windows XP machine, and I need to copy to a Windows Server 2008 machine, but this copies everything and the whole site is very large and it takes a really long time to finish copying.

Is there a way to specifically just copy new or updated files? I see you can pass in a changed-since date, but I wanted to see if there is a simpler way to compare against the destination file...

Also, I am open to using anything outside of xcopy that can do the job as well...

leora
  • 6,193

7 Answers7

129

From the XCOPY documentation:

/d[:mm-dd-yyyy] : Copies source files changed on or after the specified date only. If you do not include a mm-dd-yyyy value, xcopy copies all Source files that are newer than existing Destination files. This command-line option allows you to update files that have changed.

So, with your example, it should read:

xcopy C:\source X:\destination /s /d
Mark
  • 1,451
32

Robocopy is a good alternative as well:

By default Robocopy will only copy a file if the source and destination have different time stamps or different file sizes.

Plus, you can do a lot more - the mirror command is handy for websites where you are deleting files as well.

Matt
  • 456
3

Use the /A option. All the new or modified files will have archive attribute set.

Check the below link for details:

Xcopy command syntax and examples

Giri
  • 559
1

I have following task scheduled for ~80k files and ~2k folders:

xcopy \\sourceserver\share\ Q:\backuptarget\folder\ /i /d /y /he /C /EXCLUDE:C:\backup\list.txt > C:\backup\backup.log

the /C option continues the copy even if "access is denied" to file or folder due to it being open or not having permission under service account you run this scheduled task under.

the ">" overwrites the log each time if you want to append you can use ">>" pipe.

1

There's rsync, but I haven't used in on Windows. The way I normally use it on Linux is:

rsync -avuz src/ remote:dst/

which only sends updates (new and modified files).

jcomeau_ictx
  • 859
  • 10
  • 15
0

Good day, everyone whose are concerned. I am using Windows Server 2019 and implementing Task Scheduled as this:

XCOPY "%p01%" "%p02%" /D /S /Z

To duplicate (aka. backup) from our primary data files from server one to our secondary data folder on server two. I am trying to show you all codes but let me mask some credential to protect any company privacy. enter image description here

Let us discuss for any interest on developing anything with batch file scripting. C u in Command Prompt! :)

Rhak Kahr
  • 201
-1

BitTorrent Sync works wonderfully. It will update automatically whenever you change a file. Peer to peer. Update multiple locations at once if you need to. Easy to use.

Jon49
  • 133