This night, I had to move a complete set of databases (20 in total) from one SQL server to another. In the past that has always taken me quite some time, so this time I set out to try to do this in a more efficient manner.
First i made sure that both servers had the same databases running. I did that by hand: backup on source server, and restore on destination server. If i ever need to move siginificantly more than 20 databases, i will need a more efficient method for this as well I guess.
The problem with this is that only restoring databases is not enough. This way, the database users of the source server will not exist in the destination server, so none of the application will have access. Luckily, Microsoft provides us with a way to migrate users from one server to the other. The method is explained pretty well in this knowledge base article: http://support.microsoft.com/default.aspx?scid=kb;en-us;246133.
The gist is this: you create a helper sproc named sp_help_revlogin in the master database of the source server. Running this sproc will create an SQL script that will recreate all users (including their security IDs) in the destination database.
When this was done, I stopped all websites, stopped both Source and Destination SQL server, and copied all datafiles and log files from all user databases from the source server to the destination server. Only the user databases, not any of the system databases. Next, i added the IP address of the source server to the destination server (i always use ip addresses in my connection strings). Now it was just a matter of starting the destination sql server, and all websites.. and ready. Total downtime on websites: 8 minutes.
I might have tried other synchronisation methods (like DTS, third party tools etc), however.... I found that sometimes DNN databases get strucurally corrupt, for instance after a failed module deinstall that deletes tables, but not stored procedures. Synchronizing databases will generate quite some errors in that case.
So, these are the steps i took to migrate all databases:
- Create all necessary databases on the Destination SQL server
- Synchronize users
- Stop all websites (preferrably leave one site running to disply a friendly error message)
- Stop destination and source SQL server
- Copy all physical datafiles from source server to destination server
- Start destination SQL server
- Add source server IP address to destination server (and remove it from source server)
- start all websites