[Last Call] Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 397
  • Last Modified:

looking for best practice of sync sql database on 2 different server

here is my requirement.
1. both server run 2003 R2 XP.  p-server runs 2005 SQL work group, backup server using SQL express.
2. we have up to 30 minutes to start the backup server if prod. srv failed, and it is ok to use bcp utility to reload the data.

looks for best practices or examples.

5 Solutions
You're better off just Restoring a full backup to your express instance  
I agree.
We take a backup of our production database (obviously) nightly and copy this backup file to the test server where it is used to restore the test database. We do this for testing/development purposes but there is nothing stopping you from doing the same for DR purposes. Having the backups copied and restored overnight will save time should stuff hit the fan.

The script below is used to find the most recent .bak file and perform the restore. Obviously you need to change the paths/names/files to suit.

Don't forget to have your windows and/or SQL users already resident on the backup database server to again save time in getting back up online.
declare @address varchar(200)

select top 1  @address =  '\\servername\SQLBkup\dbname\' + right(M.physical_device_name,28)
FROM [servername].msdb.dbo.backupset S 
	INNER JOIN [servername].msdb.dbo.backupmediafamily M
 		ON M.media_set_id = S.media_set_id
WHERE S.database_name = 'dbname'
	 AND DATEDIFF(DAY,S.backup_start_date,GETDATE()) < 2
	 and right(physical_device_name,3) = 'bak'
order by S.backup_start_date desc

Restore Database dbname
	From Disk = @address 
		with  move 'dbname_Data' to 'D:\Microsoft SQL Server\Databases\MSSQL\Data\dbname_Data.MDF'
		, move 'dbname_Log' to 'D:\Microsoft SQL Server\Databases\MSSQL\Data\dbname_Log.LDF'

Open in new window

I should add that the entire above process is automated... nobody sits there at night doing this :)
Free Backup Tool for VMware and Hyper-V

Restore full virtual machine or individual guest files from 19 common file systems directly from the backup file. Schedule VM backups with PowerShell scripts. Set desired time, lean back and let the script to notify you via email upon completion.  

You don't say what your requirement is for allowable data loss. To minimize data loss in the event of the failure of the primary instance, I recommend that you do full backups nightly plus differential backups every hour or two. Also do transaction log backups on a frequent interval. Perhaps as frequent as every five minutes. All of these backups should be written to a disk NOT located on the primary database server to avoid losing them if the server becomes unavailable. It is most convenient to map a drive and write them directly to a folder on the backup server. When the primary fails, on the backup instance you then restore the most recent full backup, followed by the most recent differential backup, followed by the transaction log backups taken since the restored differential. Your data will then be within five minutes of what is was when the primary failed. You should have restore scripts prepared in advance of the failure. (Look up restore with norecovery.) If you care make a little larger investment in coding, you can implement manual log shipping (express doesn't support automated log shipping), or implement replication to keep your backup instance up to date and quick to bring on-line.

If this is a high availability situation then I suggest that you upgrade your MSDE edition and implement transaction log shipping.  This will enable both servers to be pretty much identical depending on the shipping schedule.  It will also provide a higher degree of protection and reduce your exposure to server failure.

mshox1Author Commented:
1st thank you much for useful input and comments.  I have 1 questions,  I think that is I did not know where to find the sql admin step-by-step manual, so I can turn this wonderful ideal into practices.

is this part of sql 2005 studio management tools?   please advice.  thanks

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now