Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I am trying to use robocopy to move files from a source directory to a destination directory. The problem is that an inetpub mail process monitors the destination directory, and quickly locks and deletes files placed there. Here's what seems to be happening:

1) I call

Robocopy C:\test c:\test1 /COPY:D /MOV /IPG:50 /R:1000000 /W:30 /Z /Log:C:\robolog\RoboLog.txt

Robocopy seems to ignore the /D switch, and includes this in the log:

   Source : C:\test\
     Dest : c:\test1\

    Files : *.*

  Options : *.* /COPY:DT /MOV /Z /IPG:50 /R:1000000 /W:30 

2) I suspect that Robocopy copies the data to the destination, then writes the timestamp, then deletes the file from the source directory. Because inetpub deletes some files before Robocopy can write the timestamp, I see errors in the log like this:

2011/08/18 10:17:06 ERROR 2 (0x00000002) Time-Stamping Destination File C:\test\Foo.txt

The affected files are copied, but they also remain in the source directory

3) Robocopy fails with error 9 because of the files that were copied but not deleted.

Is there a way to fix this? If my assessment is correct, then if I could get Robocopy to copy just the data and leave timestamps as a default value, that would work.

share|improve this question

migrated from serverfault.com Aug 18 '11 at 15:18

This question came from our site for professional system and network administrators.

    
I wasn't able to get Robocopy to move files atomically, I wrote my own program that turns off the external process that locks the files while files are being moved. –  RossFabricant Aug 29 '11 at 20:51
add comment

1 Answer

I've got a feeling the files are locked when you try to delete them.
Look at using Volume Shadow copy, that should ensure that you get the files you need with out them getting deleted.
Although that complicates delteting the files automatically. You'd need to write a script(another part of your current script ) to go through and clean up the files

share|improve this answer
add comment

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.