Robocopy query

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
Dos2.0
Posts: 2
Joined: 25 May 2023 04:42

Robocopy query

#1 Post by Dos2.0 » 25 May 2023 04:48

I've used robocopy for many years, but some aspects are not particularly well explained so perhaps someone here might from experience clarify something for me.

What I'm wanting to do is to backup a specific directory tree from my C: drive to a 1Tb USB drive, such that they end up with identical contents: ie if I delete some files in the source on C: that were previously copied to the USB drive on the last backup, then they should be deleted so that they remain identical.

The robocopy /MIR does this.
Robocopy /XO is supposed to "exclude older files"

But what happens is that when I run it, it copies everything across, taking hours. Of course on the first run I expect it to do that, but in subsequent runs I expect it to scoot through and ignore everything that is the same both sides, and only copy anything new, or delete anything in the destination that does not exist in the source.

Xcopy is a little more explicit:-
/D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose source time is newer than the destination time.

So it is quite clear that it will only copy newer files, making it a very quick run.
But not so in robocopy, which says:-
"/XO :: eXclude Older files." which does not seem to me to mean exactly the same thing as /D in xcopy.

My batch file is this:-
robocopy C:\Users\john\Desktop\MyStuff D:\MyStuff /mir /XO

That it seems to be ignoring the /XO switch has got me thinking of two reasons:-
1 – C: drive is NTFS and the USB drive is FAT32 and the time stamps record differently
2 – Being a removeable USB drive the time stamps become somehow out of date or incompatible

Any suggestions as to what is going on that would cause /MIR /XO to start from scratch every time?

GeoffVass
Posts: 10
Joined: 04 Oct 2021 17:34

Re: Robocopy query

#2 Post by GeoffVass » 25 May 2023 22:50

The issue is that NTFS and FAT/FAT32 have timestamps of different accuracy so whenever Robocopy checks the time stamps between the source and the destination, it looks like they're different, whereas all that's happened is the high-resolution time stamp from NTFS has been rounded to the lower-resolution time stamp on the FAT/FAT32 volume. The remedy is to use the /FFT switch so it ignores those differences. This is useful also on NAS volumes. Really any situation which is NTFS -> non-NTFS.

ohenryx2
Posts: 5
Joined: 08 Apr 2023 14:16

Re: Robocopy query

#3 Post by ohenryx2 » 26 May 2023 18:28

You could always just reformat the external USB drive to NTFS.

Dos2.0
Posts: 2
Joined: 25 May 2023 04:42

Re: Robocopy query

#4 Post by Dos2.0 » 26 May 2023 20:55

by GeoffVass » 26 May 2023 14:20

"The issue is that NTFS and FAT/FAT32 have timestamps of different accuracy "

Well that confirms my suspicion.
Many thanks GeoffVass for that and providing a solution! Not many robocopy experts around any more.

Post Reply