Author Topic: Buffalo NAS LS220D Robocopy script backup failed  (Read 2621 times)

Mercestes

  • Calf
  • *
  • Posts: 6
Buffalo NAS LS220D Robocopy script backup failed
« on: February 26, 2020, 08:39:52 AM »
I have a Buffalo NAS LS220D setup and mapped to drive N:  I run automated backup scripts on my machine using Robocopy, scripts, and Task Scheduler.  If I manually run the script myself the commands run fine, but when the task runs from task scheduler, it copies to my OneDrive directory, but not to the Buffalo NAS directory.

I'm pretty sure it's a permissions issue involving my mapped N drive and I've tried storing my NAS drive credentials in Windows credentials for the N drive and storing my local user account as part of the task, but that's been the extent of my troubleshooting.

If anyone has any experience getting robocopy scripts to run on this drive, please do let me know. 

Kane88

  • Buffalo
  • ***
  • Posts: 161
Re: Buffalo NAS LS220D Robocopy script backup failed
« Reply #1 on: February 28, 2020, 10:13:22 AM »
I run my robocopy scripts manually from batch files.  They work with this unit.

Are you backing up to the LS220D?  Or are you backing up the LS220D to something else?

What error(s) are you getting?
Are you mapping the drive on the windows pc using an account on the linkstation itself?

Scheduled tasks run from the windows system account, unless you specify which user for it to run under.
Maybe windows needs permissions to run your script for the system account.  That's what I would look at first.

I've seen it before some times where I have had to run the command prompt as a system admin (no idea why) for some robocopy scripts to run to backups also.

1000001101000

  • Debian Wizard
  • Big Bull
  • *****
  • Posts: 1128
  • There's no problem so bad you cannot make it worse
Re: Buffalo NAS LS220D Robocopy script backup failed
« Reply #2 on: February 28, 2020, 10:19:32 AM »
Network drives are mounted on a per-user basis, and I believe they are part of the actual windows session. They basically don't exist in the context of your scheduled task. I believe you can configure a schedules task to use your existing windows session but that only works if you are logged in when it runs.

If you re-work the script to use the full UNC path (\\....\....\) that may help though you still need to authenticate somehow. This is relatively simple if you and the share are part of a domain and can run the scheduled task from the context of your domain user. I believe there is a way to do it for non-domain devices but I don't know how.

Kane88

  • Buffalo
  • ***
  • Posts: 161
Re: Buffalo NAS LS220D Robocopy script backup failed
« Reply #3 on: February 28, 2020, 12:10:09 PM »
Network drives are mounted on a per-user basis, and I believe they are part of the actual windows session. They basically don't exist in the context of your scheduled task. I believe you can configure a schedules task to use your existing windows session but that only works if you are logged in when it runs.

If that's the case, I wonder what happens if he uses net use and maps the drive(s) in his script, and then deletes the mapping(s) before the script completes.

I would try net use Z: \\ls220d\sharename /user:BuffaloUser BuffaloPassword
pause

and then net use Z: /delete at the end
pause


Maybe this will work...


1000001101000

  • Debian Wizard
  • Big Bull
  • *****
  • Posts: 1128
  • There's no problem so bad you cannot make it worse
Re: Buffalo NAS LS220D Robocopy script backup failed
« Reply #4 on: February 28, 2020, 12:19:26 PM »
that sounds reasonable.

I believe they'll need to choose "Run whether user is logged on or not" so that the task can create enough of a session for mapping a drive to work.



Mercestes

  • Calf
  • *
  • Posts: 6
Re: Buffalo NAS LS220D Robocopy script backup failed
« Reply #5 on: March 11, 2020, 03:50:31 PM »

Are you mapping the drive on the windows pc using an account on the linkstation itself?


No, the user exists on my windows machine, but not on the LS220 itself.  Do I need to add a user on the LS220?  Or add a user on my windows machine?

Kane88

  • Buffalo
  • ***
  • Posts: 161
Re: Buffalo NAS LS220D Robocopy script backup failed
« Reply #6 on: March 11, 2020, 04:20:36 PM »
When you run the scheduled task, what error does it give you?

If you don't have any users already setup on your buffalo nas itself:
Then I don't understand how you are mapping N: drive to the buffalo nas, or how you're able to even access that share.
unless you're using the buffalo defaults, which would be either /user:admin password  or no /user: at all
or unless you're using AD domain authentication, which I doubt since you haven't mentioned that you are.

I map my shares with an account that was made on the buffalo nas itself.
The account has read and write access to the buffalo share I made on the device.

And then I map it in my windows session this way:
net use X: \\LinkstationNameHere\SharedFolderName /user:BuffaloUsernameHere PasswordHere


Mercestes

  • Calf
  • *
  • Posts: 6
Re: Buffalo NAS LS220D Robocopy script backup failed
« Reply #7 on: April 02, 2020, 12:53:51 PM »
Quote
When you run the scheduled task, what error does it give you?
  It doesn't give me an error.  It runs successfully if I run the schedule task.  It just doesn't work if the scheduler runs it when scheduled.

Quote
I would try net use Z: \\ls220d\sharename /user:BuffaloUser BuffaloPassword
  I'm giving this a second go.  I've removed my windows drive map and am just using the net use command in the script (It should stay mapped, but I don't care if it gets an "already mapped" error), and will see if this works.

So far, none of these suggestions have been successful however.  The script itself runs great if I run it (or execute it from task manager.)  But when it runs as scheduled at 2am it copies to my secondary drive, and fails for my Buffalo Nas mapped drive.

Mercestes

  • Calf
  • *
  • Posts: 6
Re: Buffalo NAS LS220D Robocopy script backup failed
« Reply #8 on: April 03, 2020, 08:15:08 AM »
Quote
net use X: \\LinkstationNameHere\SharedFolderName /user:BuffaloUsernameHere PasswordHere

Yea, this is still not working.  My scripts work copying to an external drive just fine, and they work copying to the NAS drive if I manually run the script, but when the task scheduler runs it it is not working.

Mercestes

  • Calf
  • *
  • Posts: 6
Re: Buffalo NAS LS220D Robocopy script backup failed
« Reply #9 on: April 03, 2020, 08:31:46 AM »
New Info:

I decided to manually recheck everything and I found mapping the drive using the Buffalo username generates a new error "cannot copy file attributes," which I have seen before.  I've updated my scripts to include /copy:DT for my robocopy scripts (Do not copy attributes.)

I will check again in the morning.

Mercestes

  • Calf
  • *
  • Posts: 6
Re: Buffalo NAS LS220D Robocopy script backup failed
« Reply #10 on: April 04, 2020, 03:12:33 PM »
Got it, thank you @Kane88.

It was a combination of using "net use N: /user:BuffaloUsernameHere PasswordHere" and updating my robocopy script to not include file attributes.

Kane88

  • Buffalo
  • ***
  • Posts: 161
Re: Buffalo NAS LS220D Robocopy script backup failed
« Reply #11 on: April 04, 2020, 10:25:37 PM »
Great!  Glad it worked out.
Though it is strange you cannot copy file attributes.  I wonder why.  I do that all the time without issue, although I'm not copying all the attributes either.  If anything, the problems I had were with timestamps.

If you want to play with it, this is one I use fairly often

just do robocopy /? to see what the rest of the switches do...

Here is one I use
robocopy "S:\SourceFolder" "D:\DestinationFolder" /E /FFT /DCOPY:DAT /COPY:DAT /V /FP /BYTES /ETA


/E copy empty dirs
/FFT FAT file timing- huge problem fix for me
/DCOPY:DAT copy dir attributes
/COPY:DAT copy file attributes

and the rest are display data
/V
/FP
/BYTES
/ETA 


I noticed in windows 7 / Server 2008 R2, you have have to do this a little different.
I could only do /DCOPY:T  with that one.


Kane88

  • Buffalo
  • ***
  • Posts: 161
Re: Buffalo NAS LS220D Robocopy script backup failed
« Reply #12 on: April 08, 2020, 06:12:31 AM »
I should also mention one other thing for anyone else reading:
if you need to retain copies of old data, do not use the above.

robocopy WILL overwrite the destination directory data, and without any warnings.  That's how robocopy works.  You will not get yes and no prompts like with windows explorer.

If you have files and folders that have the same filenames that are already backed up to the destination folder or directory, they will be overwritten by the newer source data, unless the file compare says 'same'.

This will not /PURGE existing data from the destination (directories or files that are no longer on the source- will remain in the destination directory).  You'll have to delete those manually, or add that switch at your own risk.

Purged items are permanently deleted.  They do NOT go to the windows recycle bin.  But if they are on a buffalo nas and removed from there, they will go to the buffalo trashbox- if the buffalo recycle bin is enabled.