Follow sqlserver-dba.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

SQLServer-DBA.com Links

Dba_db2_button

dba-ninja.com

SQL Server DBA Jobs

SQL Server BACKUP folder in windows registry

19 March,2007 by Tom Collins

SQL Server BACKUP folder in windows registry
*This script reads and copies  the backup folder as defined in the windows registry to an Alternative directory

/******************************************************************
*
* SQL Server BACKUP 
*This script read the backup folder as defined in the windows registry

******************************************************************/

CREATE  PROCEDURE BACKUP_DB
AS 
DECLARE @BACKUP_DIR VARCHAR(200) 
DECLARE @ALTERNATIVE_DIR VARCHAR(200)
DECLARE @CMD VARCHAR(1000)
SET @ALTERNATIVE_DIR = '\\SERVER2\SERVER1\BACKUP\'
EXECUTE master..xp_regread   
     'HKEY_LOCAL_MACHINE',
     'SOFTWARE\Microsoft\MSSQLServer\MSSQLServer', 
     ' BackupDirectory ', 
      @BACKUP_DIR OUTPUT 
      SET @CMD = 'COPY "' + @BACKUP_DIR + '\*MASTER*" ' +  @ALTERNATIVE_DIR 
      EXEC master..xp_cmdshell @CMD

GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

 Related Posts

Copy only backup in SQL server 2005 and not break the backup chain

Slow SQL Server Backup and Restore with DBCC TRACEON (3004, 3605, -1)


Author: Tom Collins (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on SQL Server BACKUP folder in windows registry


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer