create subfolder each DB when backup log performed

Answered create subfolder each DB when backup log performed

  • Tuesday, May 08, 2012 7:23 AM
     
     

    dear all

    I'm newbie on SQL Server I want to the folder will be automatically created for each DB's name when Log backup performed..???

    anybody has scripts?? please help me..

    Thanks for any helps

    Regards

All Replies

  • Tuesday, May 08, 2012 7:32 AM
    Answerer
     
     

    Old DOS command


      SET @CommandString = 'IF NOT EXIST "' + @LocalBackupPath + '\' + @name + '" MD "' + @LocalBackupPath + '\' + @name + '"'
      
      EXEC xp_cmdshell @CommandString


    Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/

  • Tuesday, May 08, 2012 7:34 AM
     
     Proposed Answer
    Use Maintenance Plan, and you will have that option.

    SKG: Please Marked as Answered, if it resolves your issue. (b: http://sudeeptaganguly.wordpress.com)

  • Tuesday, May 08, 2012 8:00 AM
    Moderator
     
     

    As Sudeepta mentioned, here is the image.


    Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker
    --------------------------------------------------------------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------------------------------------------------------------------
    My Blog | Team Blog | @Twitter

  • Tuesday, May 08, 2012 8:25 AM
     
     

    Thanks Balmukund & Sudeepta,

    But I'd like run this script(Backup Log) automatically when one of DB's used logspace > 80%....e

    is it possible with maintenance plan??

    thanks

  • Tuesday, May 08, 2012 8:28 AM
    Moderator
     
     

    Thanks Balmukund & Sudeepta,

    But I'd like run this script(Backup Log) automatically when one of DB's used logspace > 80%....e

    is it possible with maintenance plan??

    thanks

    MP don't have that kind of trigger. 


    Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker
    --------------------------------------------------------------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------------------------------------------------------------------
    My Blog | Team Blog | @Twitter

  • Tuesday, May 08, 2012 9:04 AM
    Answerer
     
     Proposed Answer
    Include in your backup script  the code I posted above....

    Best Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/

  • Tuesday, May 08, 2012 10:22 AM
     
     

    Hello Urang,

    Please see the screen shots below to get the exact procedure.

    Hope it helped you..If yes then please marked it as answer.

    All the best :)

    For more details go to the following link.

    http://msdn.microsoft.com/en-us/library/ms191002.aspx

  • Tuesday, May 08, 2012 11:35 AM
    Moderator
     
     Answered

    dear all

    I'm newbie on SQL Server I want to the folder will be automatically created for each DB's name when Log backup performed..???

    anybody has scripts?? please help me..

    Thanks for any helps

    Regards

    Yes, Ola Hallengren's scripts do this exact type of functionality:

    http://ola.hallengren.com/

    This is one of the best set of database backup, integrity check, and maintenance scripts available and it is completely free.  It's also been the winner of the SQL Server Magazine Gold Award for best free tool for the last few years.  I recommend these scripts to all of my consulting clients.


    Jonathan Kehayias | Principal Consultant, SQLSkills.com
    SQL Server MVP | Microsoft Certified Master: SQL Server 2008
    Author of Troubleshooting SQL Server: A Guide for Accidental DBAs
    Feel free to contact me through My Blog or Twitter. Become a SQLskills Insider!
    Please click the Mark as Answer button if a post solves your problem!

  • Tuesday, May 08, 2012 11:37 AM
    Moderator
     
     Answered
    The MP itself doesn't have that trigger, but the Agent Alert for logspace > 80% can execute the Backup Log job step from the MP to do the backup, so it's not impossible with MPs.

    Jonathan Kehayias | Principal Consultant, SQLSkills.com
    SQL Server MVP | Microsoft Certified Master: SQL Server 2008
    Author of Troubleshooting SQL Server: A Guide for Accidental DBAs
    Feel free to contact me through My Blog or Twitter. Become a SQLskills Insider!
    Please click the Mark as Answer button if a post solves your problem!

  • Tuesday, May 08, 2012 11:38 AM
    Moderator
     
     

    Yes, Ola Hallengren's scripts do this exact type of functionality:

    I agree with Jonathan!

    Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker
    --------------------------------------------------------------------------------
    This posting is provided "AS IS" with no warranties, and confers no rights.
    --------------------------------------------------------------------------------
    My Blog | Team Blog | @Twitter