Remote Tech Support

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Wednesday, 1 September 2010

Changing the default SQL Server backup folder

Posted on 10:23 by Unknown
ProblemWhen 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.  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.  Is it possible to change the default directory for backups, so it does not need to be specified each time I run a backup?

SolutionThe directories for the default data files, log files and backups are stored in the system registry.  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.



But if you search through all of the pages under Database Settings you will not find anything that shows the default backup directory.  To find this we need to look in the registry.
If we open the registry using REGEDIT or some other tool and if you navigate to this key:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.2\MSSQLServer or similar for your instance of SQL Server we can see the following information   The highlighted line below shows the default directory for the backups for this one instance.
 
If you want to change the value you can edit the registry value and save the new location.  So for this example let's change it to 'D:\SQLBackups'.
If I do a backup using SQL Management Studio and click on "Add" for a new destination file the following screen shows the default folder has now changed to 'D:\SQLBackups'.
Another way to change the registry is to using the extended stored procedures XP_REGREAD and XP_REGWRITE.
To read the value from the registry you can issue the following command:
DECLARE @BackupDirectory VARCHAR(100) EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE',
  
@key='SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.2\MSSQLServer',
  
@value_name='BackupDirectory',
  
@BackupDirectory=@BackupDirectory OUTPUT SELECT @BackupDirectory
This will provide the following output, since we changed the value above directly in the registry.
If we want to change this back to the default folder we can use the following command
EXEC master..xp_regwrite
     
@rootkey='HKEY_LOCAL_MACHINE',
     
@key='SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.2\MSSQLServer',
     
@value_name='BackupDirectory',
     
@type='REG_SZ',
     
@value='C:\Program Files\Microsoft SQL Server\MSSQL.2\MSSQL\Backup'
If we run this command again we can see that this has changed:
DECLARE @BackupDirectory VARCHAR(100) EXEC master..xp_regread @rootkey='HKEY_LOCAL_MACHINE',
  
@key='SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.2\MSSQLServer',
  
@value_name='BackupDirectory',
  
@BackupDirectory=@BackupDirectory OUTPUT SELECT @BackupDirectory
To determine where SQL Server is installed you can right click on the server name, select Properties.  The root directory as highlighted below will show you the corresponding install name for the instance such as "MSSQL2" highlighted below, so you know which registry entry needs to be changed.
That's all there is to it, so save yourself some time and change the default location.
Email ThisBlogThis!Share to XShare to Facebook
Posted in For System Administrators, SQL | No comments
Newer Post Older Post Home
View mobile version

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Windows Server 2008 Core Command Guide
    Windows Server 2008 Core Command Guide What Command Set DNS IP Netsh int ipv4 set dns “local area connection” stat...
  • USB Disk Security 5.4.0.12
    USB Disk Security -  Download 100% protection against any threats via USB storage USB Disk Security is a top-rated antivirus utility that pr...
  • GDS COMMITTEE IMPLEMENTATION ORDERS RELEASED BY DIRECTORATE TODAY
    GDS COMMITTEE IMPLEMENTATION ORDERS RELEASED BY DIRECTORATE TODAY POSTAL DIRECTORATE ISSUED ORDERS TODAY FOR IMPLEMENTING THE GDS COMMITTEE ...
  • (no title)
    POSTAL RATES INDEX Letters / Book Post Registered Articl...
  • Most Useful Websites
           The list primarily highlights the lesser-known or undiscovered websites and misses out all-time favorites like Google Docs, Wikipedia...
  • Commands in Windows Vista
    Windows Vista Command Line List and Reference The list of commands available in the command line shell for Windows Vista is similar to that ...
  • Save queries in Windows Server 2003's Active Directory Users and Computers tool
    Windows Server 2003 administrators can’t live without the Active Directory Users and Computers tool. Here’s a quick look at the saved querie...
  • PDF into Word ( Document) converter
    PDF into Word ( Document) Converter         PDF2Word(pdf to word) software enable export the text, images and other contents from pdf docume...
  • THIRUKKURAL PDF DOWNLOAD (தமிழ் )
    CLICK HERE TO DOWNLOAD THIRUKKURAL (தமிழ்)    or CLICK HERE TO DOWNLOAD THIRUKKURAL (TAMIL & ENGLISH)    or CLICK HERE TO DOWNLOAD THIR...
  • How to shutdown computer automatically at a specific time
    Trick 1: Start > Run Type ' shutdown -s -t 1800 ' without quotes Click OK A dialog will appear showing the countdown t...

Categories

  • Computer Guidelines
  • Customer Care
  • DB Tools
  • Drivers
  • Entertainments
  • FAQ
  • For System Administrators
  • FTP
  • General Informations
  • General Knowledge
  • Guidelines
  • Hardwares
  • Health Tips
  • Internet Tips
  • Latest Software Updates
  • Network Trouble shooting
  • Printer Trouble shooting
  • Printing Tips
  • Recovery Tips
  • Registry Tips
  • Registry Tools
  • Security Guidelines
  • Security Tips
  • Software Tips
  • Softwares
  • SQL
  • Technology
  • Tips and Tricks
  • Tools
  • Trouble shooting
  • Useful Softwares
  • Utilities
  • Virus Solutions
  • Websites
  • windows 7
  • Windows Server
  • Windows Tips
  • Windows Vista
  • Windows XP FAQ

Blog Archive

  • ►  2011 (138)
    • ►  May (32)
    • ►  April (24)
    • ►  March (29)
    • ►  February (15)
    • ►  January (38)
  • ▼  2010 (241)
    • ►  December (55)
    • ►  November (40)
    • ►  October (21)
    • ▼  September (35)
      • HP LJ 1007 Laser Printer - Driver
      • How to print to a network printer from an MS-DOS-b...
      • DISCUSSIONS ON VARIOUS ISSUES TAKEN UP BY THE STAF...
      • Tips to Prevent Computer Fraud
      • Disabling or enabling Windows XP System Restore
      • History, Facts and Information about Roman Numerals
      • Recruitment Processing Software
      • Hirens BootCD 11.0 + Multilingual Keyboard Patch
      • Actice Directory FAQ with Answers
      • Windows Server 2008 Core Command Guide
      • NIC Guide for DOP People
      • General Network Connectivity Problems
      • How to troubleshoot network connectivity problems
      • Windows Registry Editor, Task Manager Problem
      • Windows Adminstrator Password Recovery
      • Computer Vision 101: Simple Tips Your Eyes Will Ap...
      • Health Tips for Computer Users
      • ADMINISTRATOR ACCOUNTS AND VIRUSES
      • Health Tips - Heart Attack
      • Suspect SQL Server 2000 Database
      • REPORT OF THE COMMITTEE OF EXPERTS ON DISCIPLINARY...
      • How to create a "Restore Point" and how to get our...
      • Troubleshoot printer problems
      • Scientific meaning of Gaytri Manthra
      • How to Improve Printing Quality
      • How to use Remote Desktop Utility
      • How to Share Files and Printer in the Local Area N...
      • Administrator and User Passwords in Windows XP
      • Enable Vista's Built-in Administrator Account
      • How to Set Password to Protect Files or Folders in...
      • Save queries in Windows Server 2003's Active Direc...
      • How to Create Active Directory ( In Windows Server...
      • How to Join a Domain in Windows 7
      • Delete IE7 History From the Command Line
      • Changing the default SQL Server backup folder
    • ►  August (39)
    • ►  July (23)
    • ►  June (5)
    • ►  May (2)
    • ►  April (12)
    • ►  March (4)
    • ►  February (2)
    • ►  January (3)
  • ►  2009 (26)
    • ►  December (5)
    • ►  November (3)
    • ►  October (4)
    • ►  September (5)
    • ►  August (3)
    • ►  July (5)
    • ►  June (1)
Powered by Blogger.

About Me

Unknown
View my complete profile