Link to home
Start Free TrialLog in
Avatar of qvfps
qvfps

asked on

scheduling robocopy to run at night

I need to backup a couple of folders across our network to a server which is backed up.   I am trying to use Robocopy to copy any changes over to the server before the nightly backup.

I created a batch file to run robocopy on both folders and used Windows Task Scheduler to set it to run every night.

I have made sure the batch file is correct.   If I run it manually by selecting it and telling it to run as administrator it runs fine.   However it never runs from the Task Scheduler.   The user I created the task with has administrator rights on the computer, I have selected Run wit Highest privileges  and Run whether user is logged on or not.    I tried changing the user or group to another administrator account, I tried changing it from a .bat file to a .cmd file.  I even scheduled two separate tasks with robocopy itself in the action and I still can not get it to run.  I have selected wake this computer to run this task and set the computer not to go to sleep

Program/script:  c:\windows\syswow64\robocopy.exe
add arguments: c:\data y:\data /S /z /r:5 /W:5 /log:y:\robocopy.log /NP

Y is mapped to the external folder and if I run this from the command line or in a batch file it works fine.

There are no errors in the logs.  I do not get any messages on the screen.  If I try to run it from Task Scheduler nothing happens. Both users I have tried have rights to the the files/folders

The computer is running Windows 7 64 bit.
Avatar of ste5an
ste5an
Flag of Germany image

Does the account you're using with the Task Scheduler has the permissions to connect to y:? How is this drive mapped? Maybe it's not mapped at all..

1. store the log on a local drive.
2. use the UNC path instead of y:
3. use NET USE to connect to your backup drive.
Avatar of telczj9
telczj9

You could add to your script the following line to see if the y: drive is connected:
IF NOT EXIST Y: ECHO Y: DRIVE WAS NOT ACCESSIBLE > C:\MY_LOG.TXT

Open in new window

If you launch the script with elevated privileges in task manager, probably you don't see the mapped drive. Try for example to map first  the drive and then run the script. You can check if it is visible by opening a cmd both as simple user or elevated user.
ASKER CERTIFIED SOLUTION
Avatar of Lionel MM
Lionel MM
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of qvfps

ASKER

The drive is mapped.  IF I sit down at the computer and pull up Windows Explorer the drive is there and I can view/edit files.

I have tried scheduling each copy separately by specifying Robocoy and by putting the commands in a .Bat and a .CMD file with the same results.  

 I have not tried mapping the drive as the first fist step in the file.  I will try using the UNC path and mapping the drive within the script and see if either work.  

Thanks for the suggestions
@qvfps: That the drive is mapped, when you log on is almost meaningless.

The scheduled task runs normally under a different account (with local privileges only/no AD) and it's not interactive. Thus the normal logon script which is creating the mapped drive is also not executed.
If you try the script completely, all the lines then the mapped drive drive will have the same credentials as the rest of the script--try it and let me know if it works.