Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL job failing for xcopy

Status
Not open for further replies.

mkal

Programmer
Jun 24, 2003
223
US
Server: OS Windows 2003 Standard SP2, SQL 2000 SP4

I have an xcopy job that runs in a two step job. The first step backups the database the second step (cmd exec) is calling a xcopy.cmd, here's the basic commands.

C:
cd C:\MSSQL\Backup\dbName
xcopy *.BAK \\UNCName\MSSQL\Backup\ServerName\dbName /d/y

The first step which backups the database completes w/o error but the xcopy step fails with the error: Invalid drive specification 0 file(s) copied.

If I log onto the server using the account which runs the job and execute the xcopy.cmd it runs fine, coping the file with out any errors.

The weird part is I have other xcopy jobs that run just fine on other servers.

Any ideas?

Thanks!
 
What happens if you map that UNC path to a drive letter under that same profile and then use the drive letter in the xcopy command?

MissTipps

CISSP, CEH, CEI, MCT, MCDBA, MCSE 2K3, CTT+, ECSA, Security+
 
Much to my surprise that worked. I've tried mapped drives in the past with limited success so I was reluctant to go back to them.

The account that runs the job is the same account that runs both the MSSQLSERVER Service and the SQLSERVERAGENT Service so I wouldn't think permissions would be the issue. Also the UNC path uses the IP of the server not the server name.

Any ideas as to what's going on?

Thanks!
Mike
 
You still have to authenticate to UNCs. Try doing a

net use \\UNC\Sharename password /user:domain\username

or

net use \\UNC\Sharename password /user:machinename\username

in the batch file just beforehand... Though is you've got it mapped to a drive letter you should be fine.

I would also do a...

xcopy c:\pathname\*.bak \\unc\sharename\

...instead of preceeding it with a drive letter change and a CD command. That's only superstition though. I've just been burned by bad paths too often and like to specify exactly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top