Exporting and importing contact lists in Lync Server 2010

I’ve been doing a fair bit of work around coexistence and migration lately and throwing contact lists around all over the place using dbimpexp. In light of this, I thought it’d be a good idea to do up a post to help you understand what dbimpexp.exe is as it’s a super useful bit of kit to have at your disposal during a Lync implementation/migration or during day-to-day operations.

If you’ve had experience backing up or restoring OCS 2007 R2 or Lync Server, chances are you’ll be familiar with dbimpexp. It’s very helpful for moving contact lists in a DR situation or between deployments in different domains. The only constant is that the SIP address must be the same when exporting or importing, so there’s no dependency on the AD domain that the contact lists have been exported from or are being imported into.

What is Dbimpexp?

Essentially (as per Microsoft), it’s a utility for exporting, managing and importing XML files containing homed resource data from a Microsoft Lync Server 2010 SQL database. When they say homed resource data, they mean user contact lists and conference directories. Dbimpexp allows you to import or export users’ contact lists either on a per user basis or a bulk pool-wide basis.

Using dbimpexp.exe

Dbimpexp.exe is located in C:\Program Files\Common Files\Microsoft Lync Server 2010\Support on a Lync Front End Server. You’ll be running it on one of your Enterprise Edition Front End servers or your Standard Edition server to export or import users’ contact lists.

The commands are slightly different for Standard and Enterprise Edition Front Ends, so I’ll cover both in the following sections.

Exporting Contact Lists

So the first thing we want to do is get those contact lists out of one server/pool so we can have them stored to restore in the event of failure, or so we can import them into a new server where the SIP domain is the same. We can export the contact list of an individual or the contact lists of all users on the server/pool.

Standard Edition

For Lync Server Standard Edition, we run the following commands to export users’ contact lists.

For a Single User

This will export out an XML file of the contact list for the single user you specify:

dbimpexp.exe /user:<sip address> /hrxmlfile:”<path that you want to write the xml file to>”

So an example of this would be:
dbimpexp.exe /user:jmorris@justin-morris.net /hrxmlfile:”C:\justin.xml”

For all users homed on the server

This will export out an XML files of all users’ contact lists on the server/pool:

dbimpexp.exe /hrxmlfile:”<path that you want to write the xml file to>”

An example of this would be:
dbimpexp.exe /hrxmlfile:”C:\allusers.xml”

Enterprise Edition

For Lync Server Enterprise Edition, we need to specify the backend SQL instance to connect to that the rtc database resides on. Run the following commands to export users’ contact lists from your Enterprise Edition Front End pool:

For a Single User

This will export out an XML file of the contact list for the single user you specify:

dbimpexp.exe /user:<sip address> /sqlserver:”<SQL Server FQDN\instance name>” /hrxmlfile:”<path that you want to write the xml file to>”

So an example of this would be:
dbimpexp.exe /user:justin@justin-morris.net /sqlserver:”SQL01.justin-morris.net\LYNC” /hrxmlfile:”C:\justin.xml”

For all users homed on the pool

This will export out an XML files of all users’ contact lists on the server/pool:

dbimpexp.exe /sqlserver:”<SQL Server FQDN\instance name>” /hrxmlfile:”<path that you want to write the xml file to>”

So an example of this would be:
dbimpexp.exe /sqlserver:”SQL01.justin-morris.net\LYNC” /hrxmlfile:”C:\justin.xml”

Importing Contact Lists

So now that we’ve exported our contact lists from the source server/pool, we can take the XML files that dbimpexp has created and import the contact lists into the target server/pool.

The only difference between the export and import commands is that to import users, you need to specify the /import switch and the restore type switch of /restype:user (which is different from /restype:all which will attempt to import the conference directories also).

Standard Edition

For Lync Server Standard Edition, we run the following commands to import users’ contact lists.

For a Single User

This will import the contact list from the XML file for the single user you specify:

dbimpexp.exe /import /user:<sip address> /hrxmlfile:”<path where the xml file resides>” /restype:user

So an example of this would be:
dbimpexp.exe /import /user:jmorris@justin-morris.net /hrxmlfile:”C:\justin.xml” /restype:user

For all users homed on the server

This will import all users’ contact lists on the server/pool from the XML file you specify:

dbimpexp.exe /import /hrxmlfile:”<path where the xml file resides>” /restype:user

An example of this would be:
dbimpexp.exe /import /hrxmlfile:”C:\allusers.xml” /restype:user

Enterprise Edition

For Lync Server Enterprise Edition, we run the following commands to import users’ contact lists.

For a Single User

This will import the contact list from the XML file for the single user you specify:

dbimpexp.exe /import /user:<sip address> /sqlserver:”<SQL Server FQDN\instance name>” /hrxmlfile:”<path where the xml file resides>” /restype:user

So an example of this would be:
dbimpexp.exe /import /user:justin@justin-morris.net /sqlserver:”SQL01.justin-morris.net\LYNC” /hrxmlfile:”C:\justin.xml” /restype:user

For all users homed on the pool

This will import all users’ contact lists on the server/pool from the XML file you specify:

dbimpexp.exe /import /sqlserver:”<SQL Server FQDN\instance name>” /hrxmlfile:”<path where the xml file resides>” /restype:user

So an example of this would be:
dbimpexp.exe /sqlserver:”SQL01.justin-morris.net\LYNC” /hrxmlfile:”C:\allusers.xml” /restype:user

Conclusion

So as you can see, it’s a really good tool to have up your sleeve. It’s great for restoring data after you’ve had to do a force move of users or have just rebuilt a new server and have a working Front End ready to go.

If you’ve got any questions about how it works or when you’d need to use it, drop me a comment below.

37 thoughts on “Exporting and importing contact lists in Lync Server 2010

  1. Pingback: Export e Import da lista de contatos do Lync 2010 « Rodrigo Rodrigues .:. www.andersonpatricio.org

  2. Curtis Johnstone

    Hi Justin, good refresher on a very useful tool (btw, for some reason the “\” is not showing up for me in this post – e.g. on path names, etc…).

    Have you any experience using this tool to export from one Lync organization, and then changing the corresponding SIP domain address in the hrxmlfile, and re-importing it into another Lync organization?

    Looking through the hrxmlfile, I don’t see anything that ties the user and contacts to the source AD domain other than the FQDN of the SIP addresses.

    Thanks,
    Curtis

    Reply
    1. Justin Morris

      Hi Curtis, no I don’t have any experience with changing the SIP URIs around like that. But as you said, there’s nothing binding the URIs in the export to a server or domain, so it definitely might work if you manually change the SIP domain.

      Reply
  3. vibs

    hi justin,this is a very good article.my requirement is get all the phonenumber and displayname of all users in a pool.when i see the xml all details are present but xml looks complicated.is there a way to filter the user
    info in the xml if not can i know the schema/dtd of xml so that i can parse the xml easily.

    Reply
  4. Madhu

    Hi,

    dbimpexp backup of OCS 2007 r2 Contacts xml will support for Lync 2010? because we are doing cross forest Migration from OCS 2007 R2 to Lync 2010.

    Reply
    1. Justin Morris

      Hi Mike, I haven’t tested migrating contact lists from LCS to Lync myself, but users on the TechNet forums have reported that this works ok. Best to test in your own environment first also.

      Reply
  5. Oz

    Hi Mike – I get this error. I have recreated my Lync 2010 standard edition with same name, ip address etc and when I go to import contacts.xml file I get error message.

    C:\Program Files\Common Files\Microsoft Lync Server 2010\Support>Dbimpexp.exe /hrxmlfile:contacts.xml /sqlserver:ocs01ish1za.za.wspgroup.com\rtc /import /restype:user
    SQL Schema Version: 59
    User Data Schema Version : 21
    Importing Homed Resources into database…
    0 Resource(s) imported. Errors = 20.
    Errors were encountered during import.

    Can you help with this this error when importing.

    Error: Failed to import Homed Resource RtcApplication-aceec664-09cf-441a-a1ea-ce6c6ea29edb@wspgroup.com.
    AffectedUser: RtcApplication-aceec664-09cf-441a-a1ea-ce6c6ea29edb@wspgroup.com
    Details: ###50321:ImpPrepareForImport:Can not import a user that is not homed in this pool.
    ###50001:UserMgmtSetHomedResourceDataXml:Propagation
    Data for this user has not been imported. This user does not exist in AD, is
    improperly homed or has not yet been synchronized by UR. If the user still
    exists in AD, retry the import for this user after synchronization is
    complete. If the invitee no longer exists in AD, you may ignore this error.

    Reply
    1. Justin Morris

      Hi Osman,
      With errors like this on bulk import with dbimpexp, can you try and reduce the import to only importing the one user and see if you still get the error?

      Reply
  6. Oz

    Hi Justin, Tried today and all working. Not sure why it was not working before but run best practice analyzer and applied serious of patches and rebooted server. Tried after tha and imported correctly – not sure if it needed time to syncronise also.

    Reply
  7. Brazil Nut

    Hi
    I would like to export one users contacts and duplicate this contact list over 250 people. They can then add or remove as they wish. Can I use this tool to do that? Is the command the same as above?

    Reply
    1. Justin Morris

      Hi, you wouldn’t be able to achieve this with dbimpexp because it’s designed to export and import contacts either from individual SIP accounts or all SIP accounts.

      You could potentially manually modify the xml file that is exported from a single user’s contact list and try and import this into another user. I’ve not tested this and don’t know if it will work though.

      Reply
  8. fisseha

    I have encountered an issue whereby neither a batch nor a single user import works. The error message is

    [5/7/2012 1:10:38 PM]
    Error: Failed to import Homed Resource bob@cnni.org.
    AffectedUser: bob@cnni.org
    Details: Procedure or function ‘UserMgmtSetHomedResourceDataXml’ expects parameter ‘@_TargetServiceTagId’, which was not supplied.

    Any ideas?

    Reply
  9. lindecr

    Thanks for the great description. Does this work both ways, i.e. can I use the command to export all users, then use the all users xml file to import a single user’s contacts with the single user import command?

    Reply
  10. Pingback: The Lync Insider » Use DBImpExp to Export Contacts, Not CsUser: Backing Up User Data the Right Way in Lync Server

  11. Pingback: The Lync Insider: Use DBImpExp to Export Contacts, Not CsUser: Backing Up User Data the Right Way in Lync Server « Lync News

  12. eman lacuata

    Hi Justin,

    This is just awesome. Thanks for the guide. I was just wondering. Will importing the contacts to lync 2013 work if they were exported from lync 2010 and that both lync are in different forest?

    Reply
  13. Jeff

    Thanks for the great article. Also wondering, when I run an import of a user’s config one of the last lines that shows before dbimpexp.exe exits is, “Reindexing all tables and updating statistics”.

    What tables and in what databases are being reindexed exactly? The back end enterprise SQL server tables? or the local DB’s installed on each Lync 2010 front end server?

    Thanks!

    Reply
    1. Justin Morris

      Hi Jeff, this would be the Rtc database on the backend server as this is where the user contact lists are stored in Lync Server 2010.

      Reply
  14. Pingback: | augi.ath.cx

  15. Doug Fisher

    Was able to do individual import for a couple users. Trying to do an import of contacts for a couple more and get the following error:
    Error: Failed to import Homed Resource
    Details: The INSERT statement conflicted with the CHECK constraint “CK__Resource__UserAt__21B6055D”. The conflict occurred in database “rtc”, table “dbo.Resource”, column ‘UserAtHost’.
    The statement has been terminated.
    ###50001:RtcpEnsureResourceExists:Propagation
    ###50001:ImpSetContact:Propagation
    ###50001:ImppContactsXml:Propagation
    ###50001:UserMgmtSetHomedResourceDataXml:Propagation

    Have you seen this before? Any suggestions on how to resolve?

    Reply
  16. The Deep North

    Thanks for this great description Justin. I have a question: is there any way for users to export their own contacts themselves? We have a huge organization and people are changing domains all the time, so often we are rebuilding Lync accounts. The service desk would like the ability to do this (or better yet the users themselves) but we don’t want to give them access to our Lync SQL server. Are there any other ways to manage importing and exporting of contacts in Lync 2010?

    Reply
  17. Hari

    Hi,
    i have re enabled one user account in lync 2010 without taking XML file, now that user requesting old contacts list, is there any way to restore from any source like SQL DB,, your help is highly appreciated

    Reply
    1. Justin Morris Post author

      Hi Hari,

      You would need to get the SQL database mounted into a Lync pool and then extract the contact list using dbimpexp. There’s no easy/supported way to extract the contact list straight out of the SQL database.

      Reply
  18. Mahesh

    While trying to export the xml file i am getting below error. Please help.

    Error: The path “”c:LyncContact.xml”” was invalid or is not accessible.
    Details: The given path’s format is not supported.
    at Microsoft.Rtc.DbImpExp.Application.GetFullPath(String path)
    at Microsoft.Rtc.DbImpExp.Application.ValidateArgs()
    at Microsoft.Rtc.DbImpExp.Application.ParseArgs(String[] args)
    at Microsoft.Rtc.DbImpExp.Application.Main(String[] args)

    Reply
  19. XLi

    For importing all users contacts, if I don’t use the -user switch, what will happen to my existing contacts information in the SQL database? Let’s say, I have quite a few users having contacts in Lync already, I try to import another bunch users contacts there but I don’t want to import individual at a time. So the new data will be appended to the existing one or will overwrite the orig. data. TIA

    Reply
  20. louise

    Late to the game, but I am trying to use your Export Enterprise Single User script on our environment. I am receiving the error “you must provide a value expression on the right-hand side of the ‘/’ operator. It is referring to the point in the script that reads /user:person@email.com.

    It then says under the Parser Error: “ParentContainsErrorRecordException” and under FullyQualifiedErrorId: “ExpectedValueExpression”

    Please provide any insight possible, because users get very upset when we have to move them across pools and they lose all of their contacts.

    Reply
  21. Saurabh

    Thanks Justin for the knowledge share. Could you please let us know how can I export user conferences from one pool and restore the same into other pool using DBImpExp.In your article it mentions the exporting of contact list and importing but conferences restore procedure is not clear. Please help.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.