Copying An Umbraco Website

Copying An Umbraco Website

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:

  1. Backup original DB.
  2. Restore backed-up DB to new server and / or database name.
  3. Alter the schema of each table to dbo in order to avoid "Invalid object name 'umbracoDomains'." error.
  4. Remove DB access for old user against the restored DB.
  5. Remove redundant DB Schema (for tidiness).
  6. Assign DB access to new user (creating new user if required).
  7. Create new IIS website with dedicated application pool, setting any host headers etc.
  8. Copy all files from original Umbraco website to new Umbraco website.
  9. Update web.config to new DB and new user credentials.
  10. 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:

 

Umbraco DB Before Schema

 

 

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

 

Umbraco DB After Schema

 

 

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:

  1. Copy the below lines into your favourite text editing tool.
  2. Replace all instances of "{application-pool-name}" with the name of the IIS application pool used for the copy Umbraco website.
  3. Open a command prompt (using elevated administrative privileges).
  4. Navigate to the root of the copied Umbraco website.
  5. 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

Written by Richard Bowers at 20:30
Tags :

3 Comments :

Ricardo said...
It's funny, when you say building a .net aplptcaiion by using and extending the standard providers and tools enables great things I presume you mean it takes a hideously verbose, klunky and fragile platform like .NET, and makes it a little bit less hopelessly klunky, fragile and verbose. I guess it does, but if you take the time switch to java, ror or php you can do anything that's possible in .NET, but in about a fifth of the time (if you know what you're doing). And when you've finished you'll have a systeem that won't crash all the time, unlike, Umbraco, the Umbraco forums, almost all the aspx sites I've ever visited, and every Microsoft product ever built. Do you not wonder why a Microsoft OS contains ten times more code than Apple's OSX from Apple, but still looks and performs terribly? Or why Win 7 looks as good and functions as fast as a ten year old copy of OS9? It's the dot net framework stoopid.
July 27, 2012 01:15
Abhay said...
Hi,Is there a latest voerisn of the source about anywhere? The one on codeplex looks to be from May 2009 but the assemblies in the download 07/2011. Im very interested in getting a store up an running using this and i've now got it working on 4.7.1 umbraco but need some other functionality.One of the functions is order line discounts where the price comes down the more you order. Without the source im not sure how this could be implemented. Any pointers?Are there any docs in regards to the payment providers and other areas where it could be easily extended properly rather than hacking it about?Thanks!Damian
July 27, 2012 05:49
Admin Richard Bowers (author) said...
Hello Abhay,

Payment providers and and e-commerce features don't come out-the-box with Umbraco itself, it sounds like you have an e-commerce Umbraco package installed.

Dependent on the Umbraco package, it may not be possible to get a copy of the source.

I would advise navigating (in the Umbraco admin) to the Developer section and reviewing the Umbraco packages you have installed. They can be found by expanding 'Packages', then 'Installed packages'.

Once you have identified the Umbraco package, visit our.umbraco.org or Google and see if you can find further information.

Hope this helps,
Richard
July 28, 2012 02:50

Comment

Comments closed

Try our Umbraco Hosting free for 3 months