{"id":539,"date":"2014-09-30T19:59:28","date_gmt":"2014-09-30T13:59:28","guid":{"rendered":"http:\/\/dotnetsql.info\/net-sql\/?p=539"},"modified":"2015-07-09T17:03:48","modified_gmt":"2015-07-09T11:03:48","slug":"how-to-change-the-sql-server-backup-folder","status":"publish","type":"post","link":"http:\/\/dotnetsql.info\/net-sql\/index.php\/how-to-change-the-sql-server-backup-folder\/","title":{"rendered":"How to change the Sql Server backup folder"},"content":{"rendered":"<p><strong>Scenario proposal<\/strong><br \/>\nWhen you install SQL Server the path for the installation is generally something such as the following: C:\\Program Files\\Microsoft SQL Server\\MSSQL.2\\MSSQL.<\/p>\n<p>In this directory there are also folders for your DATA files and also your BACKUP files.\u00a0 Within SQL Server Management Studio you have the ability to change the default location for your Data and Log files for all new databases, but you can not change the default directory for your backups.<\/p>\n<p>Is it possible to change the default directory for backups, so it does not need to be specified each time I run a backup?<\/p>\n<p><!--more--><\/p>\n<p><strong>Solution<\/strong><br \/>\nThe directories for the default data files, log files and backups are stored in the system registry.\u00a0 As mentioned already you have the ability to change the default data and log directories using SQL Server Management Studio, by right clicking on the server name and selecting properties and navigating to the Database Settings page as shown below.<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" title=\"\" src=\"http:\/\/dotnetsql.info\/net-sql\/wp-content\/uploads\/2014\/09\/1-300x251.jpg\" alt=\"\" width=\"300\" height=\"251\" \/><\/p>\n<p>But if you search through all of the pages under Database Settings you will not find anything that shows the default backup directory.\u00a0 To find this we need to look in the registry.<br \/>\nIf we open the registry using REGEDIT or some other tool and if you navigate to this key: <strong>HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Microsoft SQL Server\\MSSQL.2\\MSSQLServer <\/strong>or similar for your instance of SQL Server we can see the following information\u00a0\u00a0 The highlighted line below shows the default directory for the backups for this one instance.<br \/>\n<a href=\"#\"><img decoding=\"async\" loading=\"lazy\" class=\"alignleft size-medium wp-image-558\" title=\"\" src=\"http:\/\/dotnetsql.info\/net-sql\/wp-content\/uploads\/2014\/09\/3-300x182.jpg\" alt=\"\" width=\"300\" height=\"182\" srcset=\"http:\/\/dotnetsql.info\/net-sql\/wp-content\/uploads\/2014\/09\/3-300x182.jpg 300w, http:\/\/dotnetsql.info\/net-sql\/wp-content\/uploads\/2014\/09\/3.jpg 433w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>If you want to change the value you can edit the registry value and save the new location.\u00a0 So for this example let&#8217;s change it to &#8216;D:\\SQLBackups&#8217;.<br \/>\nIf I do a backup using SQL Management Studio and click on &#8220;Add&#8221; for a new destination file the following screen shows the default folder has now changed to &#8216;D:\\SQLBackups&#8217;.<br \/>\n<img decoding=\"async\" loading=\"lazy\" title=\"\" src=\"http:\/\/dotnetsql.info\/net-sql\/wp-content\/uploads\/2014\/09\/2-300x162.jpg\" alt=\"\" width=\"300\" height=\"162\" \/><\/p>\n<p>Another way to change the registry is to using the extended stored procedures XP_REGREAD and XP_REGWRITE.<br \/>\nTo read the value from the registry you can issue the following command:<br \/>\nDECLARE @BackupDirectory VARCHAR(100)<br \/>\nEXEC master..xp_regread @rootkey=&#8217;HKEY_LOCAL_MACHINE&#8217;,<br \/>\n@key=&#8217;SOFTWARE\\Microsoft\\Microsoft SQL Server\\MSSQL.2\\MSSQLServer&#8217;,<br \/>\n@value_name=&#8217;BackupDirectory&#8217;,<br \/>\n@BackupDirectory=@BackupDirectory OUTPUT<br \/>\nSELECT @BackupDirectory<br \/>\nThis will provide the following output, since we changed the value above directly in the registry.<br \/>\n<a href=\"#\"><img decoding=\"async\" loading=\"lazy\" class=\"alignleft size-full wp-image-559\" title=\"\" src=\"http:\/\/dotnetsql.info\/net-sql\/wp-content\/uploads\/2014\/09\/4.jpg\" alt=\"\" width=\"280\" height=\"71\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>If we want to change this back to the default folder we can use the following command<br \/>\nEXEC master..xp_regwrite<br \/>\n@rootkey=&#8217;HKEY_LOCAL_MACHINE&#8217;,<br \/>\n@key=&#8217;SOFTWARE\\Microsoft\\Microsoft SQL Server\\MSSQL.2\\MSSQLServer&#8217;,<br \/>\n@value_name=&#8217;BackupDirectory&#8217;,<br \/>\n@type=&#8217;REG_SZ&#8217;,<br \/>\n@value=&#8217;C:\\Program Files\\Microsoft SQL Server\\MSSQL.2\\MSSQL\\Backup&#8217;<br \/>\nIf we run this command again we can see that this has changed:<br \/>\nDECLARE @BackupDirectory VARCHAR(100)<br \/>\nEXEC master..xp_regread @rootkey=&#8217;HKEY_LOCAL_MACHINE&#8217;,<br \/>\n@key=&#8217;SOFTWARE\\Microsoft\\Microsoft SQL Server\\MSSQL.2\\MSSQLServer&#8217;,<br \/>\n@value_name=&#8217;BackupDirectory&#8217;,<br \/>\n@BackupDirectory=@BackupDirectory OUTPUT<br \/>\nSELECT @BackupDirectory<br \/>\n<img decoding=\"async\" loading=\"lazy\" title=\"\" src=\"http:\/\/dotnetsql.info\/net-sql\/wp-content\/uploads\/2014\/09\/5-300x29.jpg\" alt=\"\" width=\"300\" height=\"29\" \/><\/p>\n<p>To determine where SQL Server is installed you can right click on the server name, select Properties.\u00a0 The root directory as highlighted below will show you the corresponding install name for the instance such as &#8220;MSSQL2&#8221; highlighted below, so you know which registry entry needs to be changed.<br \/>\n<a href=\"#\"><img decoding=\"async\" loading=\"lazy\" class=\"alignleft size-medium wp-image-561\" title=\"\" src=\"http:\/\/dotnetsql.info\/net-sql\/wp-content\/uploads\/2014\/09\/6-300x126.jpg\" alt=\"\" width=\"300\" height=\"126\" srcset=\"http:\/\/dotnetsql.info\/net-sql\/wp-content\/uploads\/2014\/09\/6-300x126.jpg 300w, http:\/\/dotnetsql.info\/net-sql\/wp-content\/uploads\/2014\/09\/6.jpg 425w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>That&#8217;s all there is to it, so save yourself some time and change the default location.<\/p>\n<p><strong>Thanks for reading this article,<br \/>\n<\/strong><\/p>\n<p><strong>Next steps :<br \/>\n1.\u00a0Share this with your colleagues because Sharing\u00a0 is Learning<br \/>\n2.\u00a0Comment below if you need any assistance<\/strong><\/p>\n<p style=\"text-align: right;\"><em><strong>Powered by <a href=\"http:\/\/www.codereview.co\">CodeReview &#8211; Let&#8217;s make it Better!<\/a><\/strong><\/em><\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-twitter\"><a rel=\"nofollow\" data-shared=\"sharing-twitter-539\" class=\"share-twitter sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/how-to-change-the-sql-server-backup-folder\/?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Twitter (Opens in new window)<\/span><\/a><\/li><li class=\"share-linkedin\"><a rel=\"nofollow\" data-shared=\"sharing-linkedin-539\" class=\"share-linkedin sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/how-to-change-the-sql-server-backup-folder\/?share=linkedin\" target=\"_blank\" title=\"Click to share on LinkedIn\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on LinkedIn (Opens in new window)<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow\" data-shared=\"sharing-facebook-539\" class=\"share-facebook sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/how-to-change-the-sql-server-backup-folder\/?share=facebook\" target=\"_blank\" title=\"Share on Facebook\"><span><\/span><span class=\"sharing-screen-reader-text\">Share on Facebook (Opens in new window)<\/span><\/a><\/li><li class=\"share-google-plus-1\"><a rel=\"nofollow\" data-shared=\"sharing-google-539\" class=\"share-google-plus-1 sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/how-to-change-the-sql-server-backup-folder\/?share=google-plus-1\" target=\"_blank\" title=\"Click to share on Google+\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Google+ (Opens in new window)<\/span><\/a><\/li><li class=\"share-pocket\"><a rel=\"nofollow\" data-shared=\"\" class=\"share-pocket sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/how-to-change-the-sql-server-backup-folder\/?share=pocket\" target=\"_blank\" title=\"Click to share on Pocket\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Pocket (Opens in new window)<\/span><\/a><\/li><li class=\"share-email\"><a rel=\"nofollow\" data-shared=\"\" class=\"share-email sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/how-to-change-the-sql-server-backup-folder\/?share=email\" target=\"_blank\" title=\"Click to email this to a friend\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to email this to a friend (Opens in new window)<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div><div class='sharedaddy sd-block sd-like jetpack-likes-widget-wrapper jetpack-likes-widget-unloaded' id='like-post-wrapper-76243027-539-69e136e428f2b' data-src='\/\/widgets.wp.com\/likes\/#blog_id=76243027&amp;post_id=539&amp;origin=dotnetsql.info&amp;obj_id=76243027-539-69e136e428f2b' data-name='like-post-frame-76243027-539-69e136e428f2b'><h3 class='sd-title'>Like this:<\/h3><div class='likes-widget-placeholder post-likes-widget-placeholder' style='height:55px'><span class='button'><span>Like<\/span><\/span> <span class=\"loading\">Loading...<\/span><\/div><span class='sd-text-color'><\/span><a class='sd-link-color'><\/a><\/div>","protected":false},"excerpt":{"rendered":"<p>Scenario proposal When you install SQL Server the path for the installation is generally something such as the following: C:\\Program Files\\Microsoft SQL Server\\MSSQL.2\\MSSQL. In this directory there are also folders for your DATA files and also your BACKUP files.\u00a0 Within SQL Server Management Studio you have the ability to change the default location for your &hellip; <a href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/how-to-change-the-sql-server-backup-folder\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">How to change the Sql Server backup folder<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-twitter\"><a rel=\"nofollow\" data-shared=\"sharing-twitter-539\" class=\"share-twitter sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/how-to-change-the-sql-server-backup-folder\/?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Twitter (Opens in new window)<\/span><\/a><\/li><li class=\"share-linkedin\"><a rel=\"nofollow\" data-shared=\"sharing-linkedin-539\" class=\"share-linkedin sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/how-to-change-the-sql-server-backup-folder\/?share=linkedin\" target=\"_blank\" title=\"Click to share on LinkedIn\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on LinkedIn (Opens in new window)<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow\" data-shared=\"sharing-facebook-539\" class=\"share-facebook sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/how-to-change-the-sql-server-backup-folder\/?share=facebook\" target=\"_blank\" title=\"Share on Facebook\"><span><\/span><span class=\"sharing-screen-reader-text\">Share on Facebook (Opens in new window)<\/span><\/a><\/li><li class=\"share-google-plus-1\"><a rel=\"nofollow\" data-shared=\"sharing-google-539\" class=\"share-google-plus-1 sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/how-to-change-the-sql-server-backup-folder\/?share=google-plus-1\" target=\"_blank\" title=\"Click to share on Google+\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Google+ (Opens in new window)<\/span><\/a><\/li><li class=\"share-pocket\"><a rel=\"nofollow\" data-shared=\"\" class=\"share-pocket sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/how-to-change-the-sql-server-backup-folder\/?share=pocket\" target=\"_blank\" title=\"Click to share on Pocket\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to share on Pocket (Opens in new window)<\/span><\/a><\/li><li class=\"share-email\"><a rel=\"nofollow\" data-shared=\"\" class=\"share-email sd-button share-icon no-text\" href=\"http:\/\/dotnetsql.info\/net-sql\/index.php\/how-to-change-the-sql-server-backup-folder\/?share=email\" target=\"_blank\" title=\"Click to email this to a friend\"><span><\/span><span class=\"sharing-screen-reader-text\">Click to email this to a friend (Opens in new window)<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div><div class='sharedaddy sd-block sd-like jetpack-likes-widget-wrapper jetpack-likes-widget-unloaded' id='like-post-wrapper-76243027-539-69e136e42962b' data-src='\/\/widgets.wp.com\/likes\/#blog_id=76243027&amp;post_id=539&amp;origin=dotnetsql.info&amp;obj_id=76243027-539-69e136e42962b' data-name='like-post-frame-76243027-539-69e136e42962b'><h3 class='sd-title'>Like this:<\/h3><div class='likes-widget-placeholder post-likes-widget-placeholder' style='height:55px'><span class='button'><span>Like<\/span><\/span> <span class=\"loading\">Loading...<\/span><\/div><span class='sd-text-color'><\/span><a class='sd-link-color'><\/a><\/div>","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[6,25],"tags":[87,86,90,89,88],"aioseo_notices":[],"_links":{"self":[{"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/posts\/539"}],"collection":[{"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/comments?post=539"}],"version-history":[{"count":28,"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/posts\/539\/revisions"}],"predecessor-version":[{"id":1008,"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/posts\/539\/revisions\/1008"}],"wp:attachment":[{"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/media?parent=539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/categories?post=539"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/dotnetsql.info\/net-sql\/index.php\/wp-json\/wp\/v2\/tags?post=539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}