English 中文(简体)
SQL Server 2008 Auto Backup
原标题:

We want to have our test servers databases updated from our production server databases on a nightly basis to ensure we re developing on the most recent data. We, however, want to ensure that any fn, sp, etc that we re currently working on in the development environment doesn t get overwritten by the backup process. What we were thinking of doing was having a prebackup program that saves objects selected by our developers and a postbackup program to add them back in after the backup process is complete.

I was wondering what other developers have been doing in a situation like this. Is there an existing tool to do this for us that can run automatically on a daily basis and allow us to set objects not to overwrite (without requiring the attention of a sysadmin to run it daily).

最佳回答

All the objects in our databases are maintained in code - tables, view, triggers, stored procedures, everything - if we expect to find it in the database then it should be in DDL in code that we can run. Actual schema changes are versioned - so there s a table in the database that says this is schema version "n" and if this is not the current version (according to the update code) then we make the necessary changes.

We endeavour to separate out triggers and views - don t, although we probably should, do much with SP and FN - with drop and re-create code that is valid for the current schema version. Accordingly it should be "safe" to drop and recreate anything that isn t a table, although there will be sequencing issues with both the drop and the create if there are dependencies between objects. The nice thing about this generally is that we can confidently bring a schema from new to current and have confidence that any instance of the schema is consistent.

Expanding to your case, if you have the ability to run the schema update code including the code to recreate all the database objects according to the current definitions then your problem should substantially go away... backup, restore, run schema maint logic. This would have the further benefit that you can introduce schema (table) changes in the dev servers and still keep the same update logic.

I know this isn t a completely generic solution. And its worth noting that it probably works better with database per developer (I m an old fashioned programmer, so I see all problems as having code based solutions (-:) but as a general approach I think it has considerable merit because it gives you a consistent mechanism to address a number of problems.

问题回答

暂无回答




相关问题
Backing up my database is taking too long

On a windows mobile unit, the software I m working on relies on a sdf file as it s database. The platform that the software is targeted towards is "less than optimal" and hard resets every once and a ...

Cognos LAE Backup Automation (Batch File?)

Within Cognos 7.4 security.. one would create an LAE file to export all their users... directions here... http://www.cognos-install.co.uk/articles/backups/access_manager_export_to_lae.asp Now you ...

backup SQL Server 2005 database without data

I have one stored procedure to backup the database. It will backup metadata as well as data. Is there any option to back up the database with out data. ie, back up only the schema (Empty tables). I ...

SQL Server 2008 Auto Backup

We want to have our test servers databases updated from our production server databases on a nightly basis to ensure we re developing on the most recent data. We, however, want to ensure that any fn, ...

mysql dump stops when a row is updated

When i try to get a dump of a mysql database, the dump stops when a row in it is updated. How can i prevent that? I already tried following options with no result: -f (forces continu even when error)...

热门标签