Robocopy to SMB

Jeff Devo 1 Reputation point
2022-04-22T22:33:58.923+00:00

I'm using Robocopy to copy the contents of a folder called "MSBackups", which is stored on an NTFS HDD. The Destination folder is on a Samba share on my LAN. (Samba is installed on CentOS 7.9) Robcopy uses a "bat" file and runs as a scheduled task, this has been the case for few years with no issues but during the past few of months I've started to get errors when the task runs e.g. "access denied" and "network problems".

The backup fails on one of 2 folders, \user\AppData and / or \user\Data\$OF
The work round has been to stop the task (if needed) and use WinSCP to re-apply the perms on the Destination folder.

I then run the "bat" file manually "as admin" and it usually completes without errors but sometimes it doesn't and I have to repeat the perms thing.

This seems to be a "permissions thing" and could be due to updates on either Windows 10 or with Samba. My Robcopy "bat" file has worked fine for years using the "/mir" option but something has changed that has escaped my old brain! ( I have been retired for a few years and I'm not as sharp as I used to be)

I use Robocopy to copy other folders, all as scheduled tasks and never have any problems. The issue is specific to the "MSBackups", AppData & $OF folders but I can't see why.

I'm using Samba (4.10.16 )

The bat file below has worked for several years, with no errors.

robocopy \source \Destination\Data\msbackups /MIR /NDL /LOG:C:\robotasks\logs\MSBACKtocentos.log

The /zb switch was added recently but hasn't helped.

I have amended the Robo switches to "/e /purge /NDL /LOG:C:\ etc" but that hasn't helped.

Also tried " /e /mir /NDL" but still have issue.

As far as I know, the "/mir" option should ignore the perms of the source and inherit the perms of the destination. Maybe something has changed?

The perms on the Samba shares are set to 2777 and all folders give access to the "smbgrp" and are owned by "fred".

The scheduled task is run as "fred" (user on the Win 10 box)
fred is a local admin on the Win 10 box
fred is a member of the smbgrp (Samba users)

When viewing perms (security) of the Samba share, from a Win 10 box, I get:-

Everyone - "special permissions"
fred (CENTOS\fred) - "special permissions"
smbgrp (CENTOS\smbgrp) - "special permissions"

On the Win10 box (the source of MSBackups), "fred" (Square64\fred) has "Full Control"

I don't know if this is a Samba issue or a Robocopy issue or maybe the way that MS Backup / File History works with regards to "unique perms".
The Win 10 boxes on the LAN all log on using MS credentials. When the File History / MSBackup is run (AFAIK) it / they should inherit the perms of the (destination) NFTS HDD used to store the files. This may no longer be the case!

The "bat" file is never run as a user with MS Credentials. It is only run using either "fred" (Local Admin on the Win 10 box) or as "run as admin"

Checking Effective Perms for "fred" (Square64\fred) on the Samba share (MSBackups) from Win10 box I get "Code 0x80070534 No mapping between account names and security IDs was done"

All other shares give "No Mapping as above" but don't have any issues with robocopy.

Powershell to check smb version of server.

dir \server\share

Get-SmbConnection

Results in version 3.1.1 being in use.

SMB v1.0 is disabled on Win10 boxes

It seems to be a perms thing that only affects "App Data" & "$OF" folders, which may have "unique perms" that are not over ridden?

Grateful for any suggestions. I'm sure it isn't a problem with Robocopy switches and the "No Mapping between account names" is likely to be the problem but I don't know how to fix it :-(

Windows for business | Windows Client for IT Pros | Networking | Network connectivity and file sharing
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Limitless Technology 39,931 Reputation points
    2022-04-27T08:03:06.117+00:00

    Hello

    Thank you for your question and reaching out.

    I can understand you are facing issues while backup using robocopy .

    Please note that there is no need to backup Appdata folder as its resides in User Profile folder and are used by Windows and various other Applications running on User context , So you may be receive permissions error due to ownership is assigned to SYSTEM user and also files are used by various services and application from AppData folder.

    For Example below folders are should not be backed up

    AppData\Local\Temp\
    AppData\Local\Microsoft\Windows\
    AppData\Local\CrashDumps\

    Hence I would suggest you to Exclude AppData folder from your backup and retry it one more time.


    --If the reply is helpful, please Upvote and Accept as answer--

    0 comments No comments

Your answer

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