How to move a DotNetNuke Website to another server

Feb 10 2014

Transfer DotNetNuke to another serverEither you want to test something without affecting your live website or you need to move to another hosting provider, it is sometimes necessary to move a DotNetNuke installation to a new server. In this tutorial, I will show you how to proceed correctly.

This process is done in 4 steps

  1. Backing up the original files and database
  2. Restoring the files and database to the new host
  3. Configuring the database on the new host
  4. Modifying the Web.Config file to connect to the new database

So let's get started:

Tools we will use

  • For working with the database I will use SQL Server Management Studio 2008, but your version may vary. The free express edition will do just fine.
  • You can transfer the files with whatever tool you like, in my case I will use a free FTP client called Filezilla, they have a client and a server in case you don't already have an FTP server on the destination machine
  • You can use whatever zip utility you like, even the built-in Windows zip functionality, however I find that 7-zip has a better performance and options and it is free and open source too
  • For editing text files, I tend to prefer to use Notepad++ which will highlight code for many popular file formats and is also free, but you can do the same with any plain text editor such as the windows notepad. Do not use word or wordpad, these tools are not made to work with plain text files.

Step 1: Getting our original site backups

  1. Backing up the files: We need to take a full backup of all the files in the original site folder. This step is very simple, you just have to find your site root folder and compress all the files into a zip or similar file. If you are not sure in which folder your DotNetNuke installation resides, you can login as a host to your DotNetNuke website, then navigate to Host->Host Settings and you should see the root folder of your site next to Physical Path:
  2. Backing up the database: Then we need to take a "Copy only backup" of the database. This type of backup will backup your site database without affecting any existing backup strategy in place in your SQL Server. Also, a "Copy only backup" will be a full backup (not incremental), so it will be usable to restore to another SQL Server that does not yet have a database with that name

    Crating a copy only backup in SQL Server Managent Studio

    To create a "Copy only Database Backup", open SQL Server Management Studio, login and right click on your database.
    Then select Tasks->Backup
    In the new popup, make sure you select Full in Backup type, tick the Copy only backup checkbox and take note of the file location (or choose a new one, be removing the existing one and adding another, there should be only one file listed in the Destination box). Finally click OK and make sure the operation is successful.
    If you are not sure which database it is, you can also see it in DotNetNuke in Host->Dashboard in the Database tab, at the end where the database files are shown, the database name will show there

  3. Copy the files: Now use whatever method you prefer to transfer these two files to the destination server (one compressed .zip or .7z file containing your files and one .bak file containing your database backup).

Step 2: Restoring your files and database on the new server

Restoring your files: Simply unzip your archive to the new website folder.

Restoring your database:
Restore Database to SQL Server

  1. In SQL Server Management Studio, right-click on Databases and then go to Tasks->Restore Database...

  2. In the new window, enter the database name you want to use in the To destination field. The name could be the same or a different name.

  3. Then select From device and click on the ... button and locate your file
  4. The backups available in that fil will show in the list on the bottom, you probably only have one, but if many are showing, select the most recent one having a type of Full (Copy only)
  5. Finally, click OK and make sure you get a success message

    That restores the database, however we still have a problem that the databaseOwner user probably does not exist on the new server, so we will have a problem to connect to our database if not using Windows Authentication. We will fix that in the next step.

​Step 3: Configure the database on the new host

Ok, so now we have a few things to fix on the new database, the database user and the portal alias that will be used.

  1. Fixing the user account: The problem we are facing is that the user account used by DotNetNuke to access the database is included in the backup but a matching login does not exist on the new SQL Server. We call this situation an "Orphan user". It used to be a lot of trouble to fix, and I used to just create a new user in the new server. However, I have learn a new trick just today using a system stored procedure that handles this for us easily. So I will now explain that procedure:
    1. Open SQL Server Management Studio and connect to your server
    2. Click on the New Query button
    3. Remove any code in that window and type the following, replacing databasename by your new database name

      USE databasename
      EXEC sp_change_users_login 'Report'
    4. That will show you a table containing all orphan users for that database (normally only one), take note of or copy that username
    5. Now we will create a new login with that username, right-click on Security in your server objects and click on new->login
    6. In the new window, type or paste the username in the Login name field, select the SQL Server authentication radio button and make sure Enforce password policy is NOT checked, finally select your database in the Default database field and click OK.
      Create User in SQL Server
    7. We now have a user (in the database) and a login (in the server) that have the same user name, however we still need to tell the Server that they belong together. To do that, write the following code in the query window, replacing databasename and username by your database name and your username (from previous step):
      USE databasename
      EXEC sp_change_users_login 'Auto_fix', 'username'
      If done properly, you should receive a message such as: The row for user 'username' will be fixed by updating its login link to a login already in existence... + some statistics
    8. Now, try to disconnect from the SQL Server and reconnect with the created login, if everything went fine, you should be able to login and access your database
  2. Fixing the site alias: The site alias is the domain name used to access your website, we need to add the domain name or change the domain name in the DotNetNuke database so it responds to it
    1. In SQL Server Management Studio, open your database and look for a table named dbo.PortalAlias
    2. Right-click on it and click on Edit top 200 rows, then add a record with the following info:
      PortalAliasID: nothing
      PortalId: 0 (or if you have many portals, repeat this operation for for every portal id you see in this table)
      HTTPAlias: enter the domain name you want your website to respond to
      CreatedByUserId: -1 (-1 means system, so no particular user will be assigned with this modification)
      CreatedOnDate: the current date using the format yyyy-mm-dd (unless your database does not use the neutral culture in which case enter the date like you see it in the other rows
      LastModifiedByUserId: -1 (also meaning system like for the CreatedByUserId)
      BrowserType: (you may not have that field, if you do have it leave it blank)
      Skin: (you may not have that field, if you do have it leave it blank)
      CultureCode: (you may not have that field, if you have it leave it blank)
      IsPrimary: (you may not have that field, if you have it, type True)
    3. Next we need to check if we need to change the default alias. Look for a table named PortalSettings, right-click on it and click on Edit Top 200 rows
      In the table that shows up, scroll and look in the column SettingName for a setting name DefaultPortalAlias, if you find it (you may have more than one if your site has many portals) change the domain in the column SettingValue to your new domain name.

Step 4: Modifying the Web.config file to connect to the new database

The Web.config file contains all DotNetNuke and ASP.Net configuration options. One of these options is the database connection string. If we leave it like that your site will try to connect to the old database server and may either fail or show the info from the original site and not our new copy. So we will change that like so:

  1. Navigate to your website root folder (when you extracted the .zip or .7z file) and locate the web.config file
  2. Open that file with a plain text editor (Windows Notepad, Notepad++, Programmers Notepad, etc.) Warning, do not open with Microsoft Word, Wordpad or any other rich-text editor.
  3. We have two lines to modify, one is in the <connectionStrings> section and starts with <add name="SiteSqlServer", the other is in the <appSettings> section and starts with <add key="SiteSqlServer"
        <!-- Connection String for SQL Server 2005/2008 -->
        <add name="SiteSqlServer" connectionString="Data Source=(local);Initial Catalog=databasename;User ID=userid;Password=password" providerName="System.Data.SqlClient" />
        <!-- Connection String for SQL Server 2005/2008 - kept for backwards compatability - legacy modules -->
        <add key="SiteSqlServer" value="Data Source=(local);Initial Catalog=databasename;User ID=userid;Password=password" />
    Replace (local) by your SQL server name, or leave local or user localhost, depending on how you access your new SQL Server
    Replace databasename for your new database name (if you have created a new name, if not leave it
    Replace username for your user name for that database (only if you have changed it)
    Replace password for your password also only if you have changed it
    Repeat for each of the two yellow lines above

Finally, just open a browser and navigate to your domain name and DotNetNuke should start. Note that it may take some time for the application to recompile and load on the first visits to the site. If you get a timeout on the first visit, just refresh the page.

If you get other errors, note them and either comment this post here or post in the DotNetNuke Forum, or search the error on google, etc.

This post is a bit long, but when you get used to it, the file transfer is usually the longest step in the process. If anything is unclear or you have questions, feel free to leave a comment!


Total: 1 Comment(s)
Marty Hermsen
  THANKS Daniel, you saved my day.... Thanks for your amazing great guide.... I am happy man with the DB transition to a new server....
· reply ·


Daniel Valadas 12632 9


2018 Jul  11  1
2018 Jun  26  1
2018 May  46  1
2014 Oct  2705  3
2014 Jun  4932  1
2014 Feb  3434  1
2012 Mar  1478  1

Recent Posts

Core modules development team first meeting recording
2018-07-06 12:53 PM | Daniel Valadas
Removing Roadblocks to Upgrading By Reviving the Old Core Modules
2018-06-25 4:23 PM | Daniel Valadas
How to secure a whole Dnn site with an SSL certificate
2018-05-08 4:51 PM | Daniel Valadas
Take a list of emails and separate them with a semi-colon (;)
2014-10-24 5:14 AM | Daniel Valadas
Fix: DotNetNuke users can't reset their password
2014-10-24 3:21 AM | Daniel Valadas
Fixing duplicate Display Names in DotNetNuke
2014-10-19 11:17 PM | Daniel Valadas
Creating a webservice in DotNetNuke 7
2014-06-11 1:02 PM | Daniel Valadas
How to move a DotNetNuke Website to another server
2014-02-10 10:51 AM | Daniel Valadas
World Backup Day
2012-03-31 1:28 PM | Daniel Valadas