1

I am trying to backup an external hard drive on my Windows machine to an external hard drive on my iMac running macOS Catalina. I am using Robocopy batch file to mirror the 2 drives. The code I am using is below.

robocopy F:\ \\192.168.1.100\4TBExternal\ /MIR /R:2 /W:5 /XA:SH /XF ".DS_Store" /XD "System Volume Information" "SteamLibrary" "New" "MSOCache" "Recovery" "msdownld.tmp" "found.001" "found.002" "found.003" "found.004" "found.005" "found.006" ".Spotlight-V100" ".Trashes" $RECYCLE.BIN

Previously I was backing up the external drive on Windows to an external drive on a Raspberry Pi, but I am trying to get Plex to run on my iMac, so I moved the external drive, wiped it, formated it as APFS and tried setting up the same robocopy backup system (task scheduled backups from windows). But every time I run the robocopy, the iMac locks the folder that is trying to have new files copied over. The only solution I have been able to find is to manually unlock the folders. Although I have found this code to be able to unlock the folders.

chflags -R nouchg /Volumes/4TBExternal/

I had to add smbd and Terminal as Full Disk Access in Security & Privacy in System Preferences to allow the SMB shares to even start sharing it. I also have removed all ownership ACL and then added permissions back.

sudo chmod -RN /Volumes/4TBExternal/
sudo chmod -R 1777 /Volumes/4TBExternal/

However, the robocopy batch script still locks folders when i start the script which is transfering over SMB. When I do transfers through windows explorer, there is no locking (copying a movie from F:\Movies to Y:\Movies (where Y: is \192.168.1.100\4TBExternal))

Why would that particular robocopy script be locking folders preventing anything from being copied over? I am going to dig into the SMB config file or even running that unlocking code in some sort of reoccuring way during the back up (better than nothing considering I am currently without a back up :)). Any help would be greatly appreciated. Thanks!

Also, I do not believe I have SMBv1 active on Windows. SMBv1 is not enabled in Windows Features

1 Answers1

1

I had the same issue. It occurred only when robocopy tried to create a new folder. Copying of files into an existing folder at any depth worked fine.

Solved by adding the /NODCOPY flag to the robocopy command. This flag copies the directory structure as normal, but none of the attributes. It seems that without this flag, robocopy attempts to copy folder attributes which are incompatible with MacOS which locks the folder in response (to "protect" it?).