How to sync data across multiple Umbraco environments

by Aaron Powell 9. September 2009 10:14

Recently we had a client who wanted to be able to preview content before they were publishing it live with Umbraco. Because we’d made some major modifications to the way the content was rendered we were unable to use the standard Umbraco preview since we weren’t using any of the <umbraco:item /> tags. So this posed a problem, how were we going to have the preview working?

We decided that we were going to have to have a content entry server, from here they could enter their content, publish it and view it, but how were we then to get it to the live site? The logical answer is that have a periodic push of the content entry servers database across to live, but that’s not ideal and it is a pretty nasty idea.

To add another level of complexity on top of the system the site has user generated content, this content would obviously be entered by site visitors and it would only be on the live site, not the staging site.

Hmm…

Then Shannon reminded me of a conversation which we had when we were in Denmark at CodeGarden 09, someone had suggested that you could use Red Gate’s SQL Data Compare to push the data across.
So I sat down with two copies of the database, and decided to work out what would be needed to achieve this. Essentially you need to reseed Umbraco so that when you do changes on one environment it can easily be spotted and resolved by Red Gate.

The following is the list of tables which you need to reseed:

  • cmsContent
  • cmsContentVersion
  • cmsDocument
  • cmsPropertyData
  • umbracoNode

Microsoft SQL Management Studio will be able to generate reseed scripts for these tables which will handle the data migration and everything.

With this set up it opens an interesting idea which we plan to trial, having every environment seeded differently from dev onwards and using Red Gate to migrate from one to the next.

Things to keep in mind:

If it’s likely that there will be content created/ edited on both environments make sure that you put the primary key seed to be greatly spaced. For this site we reseeded the content entry environment with a start identity of 500,000. This left a good sized buffer in the cmsPropertyData table which is the table that expands the most.

If you wanted to be able to sync across multiple environments you could do:

  • Dev – primary key index starting at 1
  • Content Entry – primary key index starting at 500,000
  • Live – primary key index starting at 1,000,000

If you want to sync more than just content (eg – Macros, Document Types, etc) you’ll have to reseed their appropriate tables too.

You still need to manually copy the Media folder across environments still, as those files aren’t stored in the database.

Categories: Umbraco

Comments

10/6/2009 7:21:00 PM #

Interesting post. I'm not a database guru so don't know all the SQL commands we have available these days, reseed is defo a new one to me.

I started a post on the forums about how best to manage multiple developers using SVN and multiple databases. This might just be another piece of the puzzle to ease how we do that.

our.umbraco.org/.../3619-Source-control-and-multiple-developers

So I've understood you right you are saying you call reseed which resets all the ID for all the mentioned tables from a given number. So not only could you have different ids for dev, staging and live but also on individual local versions too when developing locally? Then when you want to merge your mods over you just use SQL Data Compare to do the hard work?

Hows the trial going, would love to know as trying to nail down a good solution for this one.

Pete Duncanson United Kingdom

10/7/2009 3:02:08 AM #

I wouldn't recommend that each developer have their own Umbraco database as it will become a tricky management issue. With multiple Umbraco databases you'll have the possibility of people adding the same, or at least similar, items into Umbraco, particularly at the Document Type level.

Also note that the above tables are only for content and haven't been tested with sections like Macros, Data Types, etc.

AaronPowell Australia

Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading