xcopy and Robocopy deleting destination file

0

I'm trying to copy some files from one server to another's shared folder, the thing is, it works sometimes, but quite often the xcopy and robocopy commands delete the destination file upon failure, even if the backup fails I need the files to stay there.

To get into details, on the server where I'm running the commands (Windows 10) I have a bunch of Tableau files (.twbx) which are updated via a .JAR file that I run every morning with a Scheduled task.

After the files are updated I copy them to another server's share using xcopy (I later tried Robocopy to see if the problem stops happening), but when I check in the morning, the destination file is missing. It works sporadically, the issue is I need those files to always be in the share folder.

My .bat file looks like this:

I sequentially run the copy commands (one for each file since they are in diferent folder).

Robocopy E:\Tableau\TableauFileFolder \\shareserver\sharefolder\Tableau\TableauFileFolder TableauFile.twbx /mt /r:0 /log+:E:\Tableau\LogFile.log
Robocopy E:\Tableau\TableauFileFolder2 \\shareserver\sharefolder\Tableau\TableauFileFolder2 TableauFile2.twbx /mt /r:0 /log+:E:\Tableau\LogFile.log
Etc...

For xcopy I'm using:

xcopy /s/y E:\Tableau\TableauFileFolder\TableauFile.twbx \\shareserver\sharefolder\K2BAnalytics\TableauFileFolder

Directory structure is like so, on the server where I'm running the commands I have:

E:
  |-->Tableau
    |-->ShareFileFolder
      |-->ShareFile.twbx
    |-->ShareFileFolder2
      |-->ShareFile2.twbx

Share server:

sharefolder:
  |-->Tableau
    |-->ShareFileFolder
      |-->ShareFile.twbx
    |-->ShareFileFolder2
      |-->ShareFile2.twbx

My log file shows this error on the missing files:

2020/11/19 04:31:57 ERROR 0 (0x00000000) r E:\Tableau\TableauFileFolder\TableauFile.twbx
The operation completed successfully.

Admin user running the commands has full control permission on the Tableau folder of the share.

I've been having this issue for a while and I can't find a solution anywhere. I'm not using /MIR so I don't know what could be causing the destination files to be deleted.

batch-file
cmd
robocopy
xcopy
asked on Stack Overflow Nov 19, 2020 by Adrian G

1 Answer

0

As people suggested in the comments, I allowed Robocopy to make a few attempts using /R:n which has helped mitigate the issue a lot, but still isn't infallible. Some sugggested to use a smarter file copying task but I don't know of any good alternatives to Robocopy.

My commands are now like so:

Robocopy E:\Tableau\TableauFileFolder \\shareserver\sharefolder\Tableau\TableauFileFolder TableauFile.twbx /mt /r:5 /w:10 /log+:E:\Tableau\LogFile.log
answered on Stack Overflow Nov 25, 2020 by Adrian G

User contributions licensed under CC BY-SA 3.0