posts - 218, comments - 410, trackbacks - 27

My Links

Advertisement

News

Follow billgraziano on Twitter

Article Categories

Archives

Post Categories

Consulting

SQL Server

NAnt Task to Restore a SQL Server Database

In my long tradition of releasing odd utilities (ok, utility) that no one but me uses I think I've come up with a winner.  On one of my projects we've created an extensive database build process using NAnt.  This process creates the database with all its objects and runs a series of jobs to populate data.  Much of that data comes from other databases on the same server.  At the start of the build process we need to restore a series of database backups as of specific dates.  Since this script can run against a variety of developer workstations, test servers, QA servers, etc. we need to restore these backups into a variety of directories.

This NAnt task will restore a database backup onto the target server.  The task will query the server to determine the proper location for the data files and log files and move them to the proper directory.  It will also rename the files based on the database name.  It can set the database to simple recovery mode and shrink it.  It handles multiple data and log files but only restores the first backup in a backup file.

You can download the binary and the source code.  It is a NAnt task so you'll need to be using NAnt to use it.  Installation is as simple as dropping the DLL into NAnt's bin directory.

If you're running any kind of build script in your development process and aren't using NAnt I'd encourage you to look at it.  It's a great tool!

UPDATE: I've release 0.92 which you can download here: (binary and source code)

UPDATE: I've released 0.94.

Print | posted on Thursday, April 21, 2005 2:52 PM | Filed Under [ SQL Server Stuff Software Development Database Builds ]

Comments have been closed on this topic.

Powered by:
Powered By Subtext Powered By ASP.NET