Results 1 to 7 of 7
  1. #1
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,796

    Unanswered: Backup SQL to mapped drive

    Hello I am trying backup one of the database on sql server to a mapped drive

    tried this and got an error message


    Code:
    EXEC xp_cmdshell 'net use z \\WIN7PRO\sqltest'


    ERROR MESSAGE
    Msg 15281, Level 16, State 1, Procedure xp_cmdshell, Line 1
    SQL Server blocked access to procedure 'sys.xp_cmdshell' of component 'xp_cmdshell' because this component is turned off as part of the security configuration for this server. A system administrator can enable the use of 'xp_cmdshell' by using sp_configure. For more information about enabling 'xp_cmdshell', search for 'xp_cmdshell' in SQL Server Books Online.

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,858
    Provided Answers: 17
    Hello, Desireemm.

    The xp_cmdshell procedure is disabled by default on any new install of SQL Server, so you get the error.

    I think you may be making the problem a little more complex than it has to be, however. When you map a drive with xp_cmdshell, you may only get the drive mapped for that session. When the command ends, the drive mapping may go away (I have not experimented too much with that). To back up a database to a network share, all you would need to do is run
    Code:
    backup database dbname to disk = '\\WIN7PRO\sqltest\filenamehere.bak' with init
    Are you doing something else with the xp_cmdshell step?

  3. #3
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,796
    HI McCrowley thank you so much I did it but my question is will it do that every day or do I need to add that in the script??

  4. #4
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,858
    Provided Answers: 17
    I am not sure what the question is, then (sorry). Do you mean do you have to map a drive every time you back up the databases? I would be somewhat surprised if it was allowed, really. The safest thing to do is avoid drive mappings, and just back up the databases to the share itself.

  5. #5
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,796
    no I mean will it backup to the drive every day??

  6. #6
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,796
    was trying to get it to backup every day or every other day automatically

  7. #7
    Join Date
    Jan 2017
    Posts
    18
    you can easily backup of your database
    i want to recommend you to ask any question related to SQL from https://www.janbasktraining.com there multiple sQL developer for answer your question. you can also get free training of SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •