The aim of this article is to explain how to take a copy of your
Umbraco website from one environment to another (e.g. your Live
Umbraco site into your Test Umbraco area).
For these instructions, I assume the following:
- All the Umbraco pre-requisites are already installed on the
relervant web server.
- All firewall rules and other infrastructure components are
already in place.
- The new Umbraco website / instance will run under ISS in a new
application pool.
- Difference DB credentials will be used to authenticate against
the new DB.
- The DB used contains the data for a single Umbraco instance
only.
Steps to copy an Umbraco instance
At a high level, to copy and Umbraco website instance, the
following steps are folllowed:
- Backup original DB.
- Restore backed-up DB to new server and / or database name.
- Alter the schema of each table to dbo in order to avoid
"Invalid object name 'umbracoDomains'." error.
- Remove DB access for old user against the restored DB.
- Remove redundant DB Schema (for tidiness).
- Assign DB access to new user (creating new user if
required).
- Create new IIS website with dedicated application pool, setting
any host headers etc.
- Copy all files from original Umbraco website to new Umbraco
website.
- Update web.config to new DB and new user credentials.
- Apply file level permission new Umbraco web root
directory.
Alter the schema of each table to dbo in order to avoid
"Invalid object name 'umbracoDomains'." error.
When the database tables are setup during the initial Umbraco
installation, a schema is created of the same name as the specified
user and all tables are created using this schema (eg.
<SchemaName>.<TableName>). Prosumably this is to allow
multiple Umbraco sites to co-exist in a single database.
If a new user is used to access the restored Umbraco database,
Umbraco will throw an "Invalid object name 'umbracoDomains'." error
when trying to access the new Umbraco DB.
To resolve this error, the Schema of each table can be set to
'dbo' using the following SQL command against the restored Umbraco
database:
exec sp_MSforeachtable 'ALTER SCHEMA dbo TRANSFER
?'
Prior to altering the schema, the tables will look as
follows:

Once the SQL command is applies, the tables will look as
follows:

Update web.config to new DB and new user credentials.
The web.config resides at the root of the website and contains
many settings including what database the Umbaco website uses and
the credentials used.
Open web.config in your favourite text editing tool (notepad++
is a good choice), locate the umbracoDbDSN key in appSettings, then
update the elements noted in angled brackets below:
<add key="umbracoDbDSN" value="server=<DB
Server>;database=<DB Name>;user id=<User
Name>;password=<Password>"/>
Apply permission to Umbraco web root directory
Depending on how / where the source Umbraco website files are
copied from, additional unwanted permissions may have been carried
from the source. I recommend reviewing the existing security
setting and removing access which is not required prior to
continuing.
In line with best practice as per the our.umbraco.org wiki,
varying levels of security should be granted to the
ApplicationPoolIdentity against various files / folders. The
following steps can be used to apply this:
- Copy the below lines into your favourite text editing
tool.
- Replace all instances of "{application-pool-name}" with the
name of the IIS application pool used for the copy Umbraco
website.
- Open a command prompt (using elevated administrative
privileges).
- Navigate to the root of the copied Umbraco website.
- Apply the required permission by copying and pasting the edited
lines from the text editor onto the command prompt.
icacls app_code /grant "IIS
APPPOOL\{application-pool-name}":(OI)(CI)RX
icacls app_browsers /grant "IIS
APPPOOL\{application-pool-name}":(OI)(CI)RX
icacls app_data /grant "IIS
APPPOOL\{application-pool-name}":(OI)(CI)M
icacls bin /grant "IIS
APPPOOL\{application-pool-name}":(OI)(CI)R
icacls config /grant "IIS
APPPOOL\{application-pool-name}":(OI)(CI)M
icacls css /grant "IIS
APPPOOL\{application-pool-name}":(OI)(CI)M
icacls data /grant "IIS
APPPOOL\{application-pool-name}":(OI)(CI)M
icacls masterpages /grant "IIS
APPPOOL\{application-pool-name}":(OI)(CI)M
icacls media /grant "IIS
APPPOOL\{application-pool-name}":(OI)(CI)M
icacls python /grant "IIS
APPPOOL\{application-pool-name}":(OI)(CI)M
icacls scripts /grant "IIS
APPPOOL\{application-pool-name}":(OI)(CI)M
icacls umbraco /grant "IIS
APPPOOL\{application-pool-name}":(OI)(CI)M
icacls usercontrols /grant "IIS
APPPOOL\{application-pool-name}":(OI)(CI)R
icacls xslt /grant "IIS
APPPOOL\{application-pool-name}":(OI)(CI)M
icacls web.config /grant "IIS
APPPOOL\{application-pool-name}":(OI)(CI)M
icacls web.config /grant "IIS
APPPOOL\{application-pool-name}":M
icacls robots.txt /grant "IIS
APPPOOL\{application-pool-name}":M
Please feel free to submit a comment if you would like further
details / clarification of any step.
Remember to visit our Umbraco Hosting for an easy way to have
a new Umbraco instance setup in minutes.
Richard