Share via

Question on ROBOCOPY

Hram Admin 350 Reputation points
2025-07-16T08:30:22.59+00:00

Hello!

First off: where am I supposed to post questions on PowerShell now??? After selecting tag Windows for buiness\Windows Server I don't see any PS-related tag ...???

The problem: there's the daily script I've been using flawlessly for already ~4 months - the main command in the script is this:

robocopy SourceFOLDER DestinationFOLDER /e /copy:DAT /mt /z /xo /LOG:Log.txt

The keys being used here mean the files/folders from the source folder must be copied to the destination folder; if there're any files in the source folder that are older than those in the destination folder - don't copy them. There are NO switches that delete objects in the target folder!

In this configuration the destination folder often becomes larger than the source because some subfolders of the source folder can be deleted (when the project completes its subfolder is deleted from the SourceFOLDER) - it's normal and by design (sometimes we manually remove the contents of the target folder and start coping from scratch).

Yesterday the size of source was 5.38 TB, the size of the target - 5.88 TB,

Today the size of the source is just 4.1 TB.

The question: what could have happened to the script that caused it to delete some files/folders from the target directory if there are no robocopy keys that could do that???

Regards,
Michael

Windows for business | Windows Server | Networking | Other
0 comments No comments

1 answer

Sort by: Most helpful
  1. Henry Mai 8,220 Reputation points Independent Advisor
    2025-07-18T01:09:01.8233333+00:00

    Hello Michael, I am Henry. I'd like to share some insights regarding the issue. 

    Just checking—have you had a chance to look at the Log.txt file? It seems the deletion may have come from one of two sources:

    1. The robocopy command was changed.
    2. Another process deleted the files.

    You can refer to the following checks to investigate further:

    1. Examine the Header: At the very top of the log, robocopy lists the exact command that was executed. Verify that it matches the command you posted.
      • /MIR (Mirror): This makes the destination an exact copy of the source, deleting anything in the destination that doesn't exist in the source.
      • /PURGE: This is functionally the same as /MIR when used with /E.
    2. Examine the Summary: At the bottom of the log, check the "Deleted" line in the summary table. If it shows a non-zero value for files or directories, the robocopy command itself performed the deletion because it was run with /MIR or /PURGE.

    Hope this points you in the right direction for troubleshooting.

    Was this answer helpful?


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.