x

How do I copy 2 most recent bak files from one share to another over the network

I have a request from a vendor to copy two most recent backup files from a network share to a different network share.Does anyone have a PowerShell script to accomplish this task? I tried using robocopy to copy the files from share A to share B using windows batch file scheduled as a job in SQL server agent but the job keep failing. However, the batch file works fine when run manually by double clicking on it.Any pointers folks? Thanks, folks. Here is a snippet of the code used in my batch file: ROBOCOPY \\shareA\site\servername\Databasename\FULL \\shareB\SQLDumps /maxage:2

more ▼

asked Jul 17 at 12:40 PM in Default

avatar image

zillabaug
481 3 5 15

What's the error when the job fails?

Jul 17 at 01:08 PM JohnM

Executed as user: NT Service\SQLSERVERAGENT. ...Process Exit Code 3. The step failed. The error msg in the history isn't detailed to troubleshoot

Jul 17 at 01:52 PM zillabaug
(comments are locked)
10|1200 characters needed characters left

1 answer: sort voted first

The SQL Agent account, NT Service\SQLSERVERAGENT, is a local computer account which doesn't have permission to the file shares within the network. As the documentation mentions,

The SQL Server Agent service startup account defines the Windows account that SQL Server Agent runs as, as well as its network permissions

There are several ways to correct this. Here are the first few ways that come right to mind...

more ▼

answered Jul 18 at 08:53 PM

avatar image

KenJ
25k 3 10 20

(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x78
x67
x10
x5
x4

asked: Jul 17 at 12:40 PM

Seen: 32 times

Last Updated: Jul 18 at 08:53 PM

Copyright 2017 Redgate Software. Privacy Policy