0

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

5
  • to clarify: 1) the folder is not locked and then suddenly is locked before robocopy can actually transfer files?; 2) "any type of transfer" includes transfers not using robocopy (manual copy etc.) over SMB?; 3) windows deprecated SMBv1 support for security, have you manually re-enabled it and if so have you tried disabling it?
    – Yorik
    Commented Nov 30, 2022 at 18:01
  • 1) correct. i have to unlock every folder that has something copied into it. But for some reason i can copy into the /Volumes/4TBExterna/ main folder just fine. 2) yes 3) I haven't done anything on the windows side in regard to SMBv1. I will dry disabling that now. Commented Nov 30, 2022 at 19:17
  • Perhaps check open file handles from both sides for clues: ( stackoverflow.com/questions/20974438/… ) and ( learn.microsoft.com/en-us/sysinternals/downloads/handle ) I see some chatter about a bug with SMB+mac+finder thumbnail/preview locking and not releasing.
    – Yorik
    Commented Nov 30, 2022 at 19:35
  • Doing some more debugging, its just robocopy that is locking folders. Manually copying folders in windows explorer (from F:/Movies into \\192.168.1.100\4TBExternal\Movies) which is a SMB transfer is allowed and doesn't lock anything. Commented Nov 30, 2022 at 21:13
  • I have over the last week populated the drive with manual copies and since then, robocopy will only lock some folders. It is enough to be functional, but it would be really helpful to remove the copy locking the folders to make the back ups more robust so I don't have to manually check logs regularly. :) Commented Dec 3, 2022 at 19:57

1 Answer 1

0

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?).

2
  • 1
    Please post more details about your answer, such as info what /NODCOPY exactly does.
    – Destroy666
    Commented Apr 10, 2023 at 23:51
  • This worked! It looks like it doesn't copy directory info such as attributes, data, and timestamps. Commented Apr 12, 2023 at 1:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .