Australian cloud for business software — built and run in Sydney since 2002

NetLeverage
NetLeverage

Robocopy error 5 "Access is denied" and error 1314 "A required privilege is not held by the client"

Technical article
Troubleshooting

About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.

Robocopy reports Windows error 5 when the account running it cannot read or write a file or folder, and error 1314 when the account does not hold a privilege that the copy asked for. Microsoft lists them as "Access is denied." (5) and "A required privilege is not held by the client." (1314). The fix depends on which path was refused and which copy flags you gave. Read the log, check the account's privileges, prove the cause on a small real copy, then decide between /B or /ZB (backup mode) and a narrower /COPY set.

Do not "fix" either error by granting your own account full control on the whole source. Backup mode exists to read files without altering their permissions.

What the error means

Error 5 is ERROR_ACCESS_DENIED. Error 1314 is ERROR_PRIVILEGE_NOT_HELD. They are different failures. Error 5 says the permissions on a file, folder or share do not allow the operation for this account. Error 1314 says the operation needs a user right (a privilege) that the account's token does not carry.

Robocopy has two switches aimed at the first problem. Microsoft documents /b as copying "files in backup mode. In backup mode, robocopy overrides file and folder permission settings (ACLs), which might otherwise block access." It documents /zb as copying "files in restartable mode. If file access is denied, switches to backup mode."

Backup mode relies on a user right. The "Back up files and directories" right "determines which users can bypass file and directory, registry, and other persistent object permissions for the purposes of backing up the system", and is "effective only when an application attempts access through the NTFS backup application programming interface (API)". Its defaults on workstations and servers are Administrators and Backup Operators; on domain controllers Server Operators is added. The matching "Restore files and directories" right covers writing: it "determines which users can bypass file, directory, registry, and other persistent object permissions when they restore backed up files and directories, and it determines which users can set valid security principals as the owner of an object". Its default groups match: Administrators and Backup Operators, plus Server Operators on domain controllers.

The /copy flags decide how much the copy asks for. Microsoft lists D (data), A (attributes), T (time stamps), S (NTFS access control list), O (owner information) and U (auditing information). The default is DAT. /copyall equals /copy:DATSOU, and /sec equals /copy:DATS. A job that adds S, O and U asks for more than the default. Microsoft's pages do not say which right each of S and U needs, so treat the flag set as a variable to test.

Retries matter too. The documented defaults are /r of 1,000,000 retries and /w of 30 seconds. One file that keeps failing can hold a job for a very long time: 1,000,000 retries at 30 seconds is 30,000,000 seconds, about 347 days.

Likely causes

Cause What you see How to confirm
The account cannot read some source files, and backup mode is not on Error 5 on files or folders with restrictive ACLs Small real copy of one failing folder with /COPY:DAT, then check the ACL on the failing path
The account cannot write to the destination Error 5 on the destination path, including the first file Create a test file in the destination as the same account
/B or /ZB was given, but the account lacks the backup right Error 1314 whoami /priv does not list the backup privilege
The /COPY set includes S, O or U and the account lacks a right the extra data needs Error 1314 only on copies that carry the extra data Repeat the small real copy with /COPY:DAT, then with the job's flag set, and compare the logs
Share permissions block the account before NTFS is consulted Error 5 on every file of the share Check share permissions as well as the file system ACL
Encrypted files copied without the right mode (a possibility to test, not a documented symptom) Errors limited to encrypted files Microsoft documents /efsraw for "all encrypted files in EFS RAW mode"; test one encrypted file with and without it

Prove the cause before changing anything

Steps 1 and 3 only read. Steps 2 and 4 are small real copies into a scratch destination, because a listing run attempts no copy and may not show these errors. Microsoft documents /l as "files are to be listed only (and not copied, deleted, or time stamped)". A clean /L log therefore proves nothing about these errors.

First, find out who is running the copy and what that account can do. whoami /priv "displays the security privileges of the current user", and whoami /groups shows group membership:

whoami /priv
whoami /groups

Run them in the same session and as the same account as the failing job. A scheduled task can run as a different account from the one you test with.

Second, run a small real copy. Pick one small folder that failed in the job's log, use the same account, and copy only data, attributes and time stamps into a new, empty scratch folder:

robocopy \\fs01\Finance\Reports D:\Scratch\proof1 /E /COPY:DAT /R:1 /W:1 /LOG:C:\Logs\proof1.log /TEE

/log writes status to a file and /tee also writes to the console. Read the log for the exact path attached to each error. The pages cited do not give the log line format, so read your own log rather than matching text. Error 5 here, on a source path, points at read permission; error 5 on the scratch destination points at write permission.

Risk: this step writes real copies of the source files into a new place. Impact: anyone who can read the scratch folder can read those files, and the source is not changed because the command copies and does not move. Back-out: put the scratch folder where only the testing account can reach it, and remove the scratch folder when the test is finished.

Third, check the exit code. Microsoft says "any value equal to or greater than 8 indicates that there was at least one failure during the copy operation". A code of 8 means "Several files didn't copy".

Fourth, repeat the small copy into a second empty scratch folder with the flag set of the real job, for example /COPY:DATSO, and compare the two logs. If error 5 stays in both, the problem is read or write permission. If 1314 appears only when you add S, O or U, the added data is what the account lacks a right for.

robocopy \\fs01\Finance\Reports D:\Scratch\proof2 /E /COPY:DATSO /R:1 /W:1 /LOG:C:\Logs\proof2.log /TEE

Risk: this step writes a second real copy of the same files, and with S and O it also writes owner and access control data onto the scratch folder. Impact: the same exposure as the previous copy. Back-out: remove the second scratch folder when the comparison is done.

Fix

Work through the cause you proved.

Error 5 on the source. Run the copy as an account that holds the backup right, and use /ZB. Microsoft describes /zb as restartable mode that switches to backup mode if access is denied.

Risk: backup mode reads files that the account's own permissions would block, and it copies them to a place with a different ACL. Microsoft's own security note says users who can bypass permissions "could take the media to a non-domain computer on which they have administrative privileges, and then restore the data". Restrict who runs it and protect the destination. There is no undo for data that was copied somewhere it should not be, so decide who may see the copy first.

Error 5 on the destination. Give the copy account Write permission on the destination folder and share, or copy to a destination that account owns. Do not widen the source.

Risk: a Write grant lets that account add, change and overwrite files in the destination for as long as it stands. Impact: anything else that reads that destination sees what the account writes. Back-out: write down the destination's existing permissions before the change, and when the job is finished remove the grant you added, so the permissions match what you wrote down.

Error 1314. Give the account the right the copy needs. For /B and /ZB that is "Back up files and directories", which Administrators and Backup Operators hold by default. Backup Operators also holds "Restore files and directories" by default. If 1314 appears only when S, O or U is in the flag set, Microsoft's Restore page names writing files back and setting an owner, and says nothing on the S and U data. Do not guess a right: use /COPY:DAT and accept the destination's inherited permissions, or test the flag set on the small real copy.

Risk: adding an account to Backup Operators, or to the user-right setting, gives it the ability to read every file on the server through the backup right, and to write files and set owners anywhere through the restore right that the same group also holds. Microsoft advises restricting the backup right "to members of the IT team who must back up organizational data" and, where backup software uses a service account, giving it to that account only. To back out, remove the account from the group or setting. Microsoft says a change "becomes effective the next time the owner of the account logs on", so a running job must be restarted under a new sign-in.

Copy flags. If you do not need owner, access control list or auditing data, run with /COPY:DAT and accept that permissions on the destination come from its parent. If you do need them, use /COPY:DATSO or /COPYALL, but only after the small real copy with that flag set finishes without 1314. Risk: these flags write owner and access control data onto the destination, changing who can open them there. Back-out: record the destination permissions before the copy, and set them back if access is wrong.

Retries. For a first run, set small values such as /R:2 /W:5 so one bad file does not stall the job.

Encrypted files. Add /efsraw only if you need encrypted files copied in raw mode. Microsoft says /mt cannot be used with /efsraw.

Confirm the fix

Start the job from a new sign-in of the account, because a rights change applies at the next logon. Repeat the small real copy with the job's flag set, into a new empty scratch folder, and read your own log. It should list no error 5 or 1314 lines and the exit code should be below 8. Do not use /L for this check. Then spot-check the permissions on a few copied folders with the Security tab, to confirm the owner and ACL came across if you asked for them.

Example (illustrative): an administrator copies \\fs01\Finance to D:\Migrate\Finance as CONTOSO\svc-migrate with /E /COPY:DATSO /R:2 /W:5. Of 18,400 files, 37 fail. 37 divided by 18,400 is about 0.2 per cent, and the exit code is 8. A small real copy of one failing folder with /COPY:DAT also fails, so the account cannot read it, and whoami /priv shows the account lacks the backup privilege. The failures are on folders with restricted ACLs. The administrator adds svc-migrate to Backup Operators on the source server, signs in again, and reruns with /ZB. The 37 failures drop to zero. With the retry settings used, one failing file would have cost 2 retries at 5 seconds, 10 seconds, instead of the default 30,000,000 seconds.

What to watch afterwards

  • Keep the log. A job that finishes with exit code 8 or higher failed somewhere, even if it looks complete.
  • Remove temporary membership of Backup Operators when the migration ends. Risk: the account loses the backup and restore rights, so any /B or /ZB job that relies on it fails with error 1314 from then on. To back out, add the account back and start the job from a new sign-in.
  • Compare permissions on the destination after the first full copy.
  • If you are copying to keep a second version of the data, note that Microsoft describes /mir as equivalent to /e plus /purge, and /purge "deletes destination files and directories that no longer exist in the source". A mirror follows the source; it does not keep earlier versions.

Risks and limits

These commands have not been run or lab-tested.

Microsoft's pages do not show robocopy's log line format for error 5 or 1314, and do not say which privilege each of the S, O and U flags needs beyond the descriptions of the backup and restore rights. The rights pages are Windows 10 and Windows 11 policy pages; confirm the rights in your own Group Policy editor on the server. They do not describe how backup mode behaves when the source is a remote share, where the share server's own permissions apply. If one account is blocked at the share, fix the share first.

Sources