Robocopy fails in Scheduled task with ERROR 1326 Logon failure

1

My aim: To simply mirror a database backup directory onto another server

Approach: Use Robocopy statement contained in a scheduled task

robocopy "C:\MylocalDirBackup" "\\MY.IP\DatabaseBackupsShare"  /mir /z /log:"C:\MyLocalDIR\RobocopyTestLog.txt"

Environment:

  • Windows Server 2008R2
  • Scheduled task user "MylocalUser": Local adminon local machine
  • Network config: Both servers on workgroup

Tests:

  • navigate to share \MY.IP\DatabaseBackupsShare as "MylocalUser" - success, no prompt for credentials
  • Run robocopy command from command line when logged on as "MyLocalUser" - success

The Problem!: When running Robocopy command from a scheduled task the following error is raised:

2013/10/22 20:04:57 ERROR 1326 (0x0000052E) Accessing Destination Directory \\MY.IP\DatabaseBackupsShare\ Logon failure: unknown user name or bad password.

I found several other people who are having similar problems, and followed suggestions here: http://social.technet.microsoft.com/Forums/scriptcenter/en-US/b591346e-3ed0-4ed1-9453-24851ebe1bb1/scheduling-robocopy-to-run-at-system-startup?forum=ITCG

Any help gratefully received. I thought this was going to be a quick task...

windows-server-2008
scheduled-task
batch
robocopy
asked on Server Fault Oct 22, 2013 by reticentKoala • edited Oct 22, 2013 by squillman

4 Answers

1

When I was doing something similar, I was unable to get it to work without first mapping the drive.

Action 1 in Task Scheduler:

net use z: \\MY.IP\DatabaseBackupsShare mypass /user:myuser

Action 2 in Task Scheduler:

robocopy "C:\MylocalDirBackup" z:  /mir /z /log:"C:\MyLocalDIR\RobocopyTestLog.txt"

Because you're storing the password--ew--use an unprivileged account rather than an admin and give that account a strong password, the least possible privileges for the task, etc.

answered on Server Fault Oct 22, 2013 by Katherine Villyard
0

I would post this as a comment/reply but I don't have enough rep to do that.

How exactly are you launching the scheduled task?

When I've done scheduled tasks with robocopy, I put the entire robocopy command in a .bat file, and then use that for the scheduled task. In other words, I'm NOT scheduling robocopy.exe and specifying runtime parameters - I'm just scheduling the .bat file. You can avoid a lot of syntax issues that way.

answered on Server Fault Oct 22, 2013 by jlehtinen
0

are you specifying the account used in the scheduled task? Or are you using the local user? I am with @Katherine about not storing the credentials in the script. If you specify them in the task, you can tell it to use a privileged account. That way you aren't storing it in an easily access space and you can run with a different account for the script on login...

answered on Server Fault Oct 22, 2013 by MikeAWood
0

After confirming that task scheduler was indeed using the account expected but still failing I have arrived at a solution using a pass through authentication approach.

  • I created a new local user account at the destination server - MyNewLocalUser
  • I created a new local user account at the host server MyNewLocalUser
  • Both have the same username and password
  • Changed the scheduled task to run under MyNewLocalUser

Robocopy runs successfully when the task is run under this new user.

answered on Server Fault Oct 23, 2013 by reticentKoala

User contributions licensed under CC BY-SA 3.0