Maintenance Plan DB Backups to a UNC using a DNS alias failing

  • I am attempting to use a DNS alias as the hostname for my backup location in my db maintenance plans, and it is failing.

    I have isolated the problem to the xp_create_subdir extended store procedure.

    Lets say the path where I want my SQL Backups to go is \\fileserver\sqldumps

    Fileserver is IP address 10.10.10.10

    I create an A record in DNS for hostname alias to 10.10.10.10

    I can do a start, run \\fileserver\sqldumps and \\alias\sqldumps with no errors, so the path is good, permissions are good, and name resolution is good.

    In SQL Management Studio, if I open a query window and execute this command (same credentials)

    EXEC master.dbo.xp_create_subdir N ‘\\fileserver\sqldumps’, it runs successfully

    If I replace fileserver with alias, as in..

    EXEC master.dbo.xp_create_subdir N ‘\\alias\sqldumps’

    the store procedure fails with

    xp_create_subdir() returned error 123, 'The filename, directory name, or volume label syntax is incorrect.'

    I thought maybe the store procedure might be wanting to do a WINS lookup, so I added the alias to WINS, with no change in behavior..

    So, I am at a loss as to what might be going wrong. Any ideas greatly appreciated.. The thought process here is that we have a central location where our SQL Backups go, and if we decide to move that location, we can make 1 central change in DNS to point the backup location elsewhere rather than have to touch a bunch of maintenance plans across multiple servers.

    Appreciate any help with this

    Jim

  • When you setup the alias name was that done in DNS so that everyone would be able to find this file server as the alias or was this only completed on the SQL Server via the Hosts file? Based on the scenario I'm guessing that this was a change made on the DNS so that anyone could use the "\\alias" to get there.

    It's possible that you need to refresh the local DNS table on the SQL Server. Open command line and run these commands individually:

    ipconfig /flushdns

    ipconfig /registerdns

    Wait a little while and attempt the operation again and see if you get different results.

    Regards, Irish 

  • Jeffrey, thanks for the suggestion. However, been there, done that.

    It is in DNS, so everyone can get to it, and the host that running the maintenance plan has the correct DNS pointer as demonstrated by it's ability to access \\alias from anyplace but the extended store procedure

    Jim

  • For kicks and grins (a.k.a. troubleshooting purposes) try adding that file server to the hosts file and see if that works. If it does, then perhaps SQL Server is misinterpreting your command or is not able to fully bind to TCP/IP.

    Regards, Irish 

  • Jeffrey, I work with Jim, and tried that too. No luck.

  • Are you using a FQDN in there for the alias?

  • In the stored procedure, I tried passing both the alias and the FQDN version of the alias with the same result..

    I have not done any testing yet with the HOSTS file in the lab. I will give that a try later today

  • Hmm, this is a head scratcher to say the least.

    Okay, so now I have to stop outside the box and look at this again.

    So the message says that the account that runs the SQL Agent does not have rights to create a new directory. Maybe this is the issue?

    What kind of Server is this shared directory on? I tried to duplicate this here, with host files rather than DNS so it's not exactly the same, and I could not duplicate the error. However, I had SQL on both Servers with the same Agent Account.

    My theory is that the rights are not quite right, but I am not sure why.

    Regards, Irish 

  • One correction, it is a DNS CNAME alais, not an A record.

    Just checked security, even at the DNS level, not knowing if it has to be applied there too, but I did. All is correct.

    When I change the FQDN to the alias in Enterprise manager, I get the error "The directory you have specified is invalid. Are you sure this is what you want?"

    When I say yes, the job fails.

  • Server 2003 standard edition SP2.

  • So the directory is perceived as invalid.

    If you use the IP address of the server, that would be independent of DNS.

    Some things to try, RDP to a Server as the user that runs the SQL Agent Service. Once connected try to connect to that file share using the various methods you've listed fro the run prompt. Somethings got to give here.

    Other thing I just thought of but did not ask before, is the SQL Agent account a domain account and not Local or Local Service or something like that?

    Regards, Irish 

  • Just a WAG - but have you tried cycling SQL Server Agent? If not, try that and see if it has any affect.

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • I created a similar scenario maintenance plan.

    I posted part of my solution in my blog:

    http://dbalink.wordpress.com/2008/07/12/how-to-create-dynamic-file-system-directory-in-tsql/

    Hope that helps.

    -Marlon Ribunal

    SQL Server Database Administrator

  • This is curious, the store procedure does not work with an IP address either

    Just opening a query window in Management Studio,

    Fileserver is the servername

    10.0.3.103 is the IP address of the server

    backups is the sharename

    junk is the directory in the share

    EXEC master.dbo.xp_create_subdir N ‘\\fileserver\backups\junk’ Works fine

    EXEC master.dbo.xp_create_subdir N ‘\\10.0.3.103\backups\junk’

    or

    EXEC master.dbo.xp_create_subdir N ‘\\alias\backups\junk’ does not work

    Funny though, if I create a share on the local SQL server, and go at it with IP address, it works...

    I've had enuff of this game.. Use the real server name and be done with it

    Thanks for everyones help

    Jim

  • I actually used the IP address of the server in my script:

    SET @path = N‘\\[MY IP HERE]\Backup\’ + @folderdate + ‘\‘

    SQL Server Database Administrator

Viewing 15 posts - 1 through 15 (of 15 total)

You must be logged in to reply to this topic. Login to reply