Friday, August 26, 2016

How to migrate lists in SharePoint Online with Virto Backup & Recovery tool

In this post we will consider an example of list migration between site collections in SharePoint Online.

We have the following "out of the box" solution:

Save the list as a template (list settings -> save list as template), download saved template from the List Template Gallery, and load it in the List Template Gallery at the site collection, where we want to restore the list.

This option works properly only if the list does not have column types “Person” and “Lookup”.

migrate lists in SharePoint Online 1


“Person” column may be restored, but its values may not correspond to the original list. The values ​​in the “Person” type columns are stored as 19; #User Name (where 19 is ID User and User Name is username) and restored by their ID. User ID is unique within the site collection. That is why when you transfer the list to another site collection, this ID may be assigned to another user or do not exist at all.

Lookup field also can`t be restored with the List Template. Even if we restore the list with lookup field by saving as a template, the values from lookup will not be restored. The ID of list from the referenced column is stored in the list template. And the list receives a new unique ID after restoring from a template.

We can use Virto SharePoint Online Backup & Recovery tool to solve this issue.

Virto Backup & Recovery Cmd is a migration solution that allows you to save / restore data in SharePoint Online.

We will examine the solution with Virto Backup & Recovery in the example below.

I have created two lists: Test_List and Test_List_2.
In Test_List list are added two fields:
- Person (type Person or Group)
- MyLookup (type Lookup) that refers to the Title field from the list Test_List_2

migrate lists in SharePoint Online 2
Virto SharePoint Online Backup & Recovery saves in backup a great amount of data by default (users, lists, group, etc.) But I need to move two lists only. In this case, I should create a configuration file.

Find Config.xml file in the folder with the utility (virtobr.exe). Copy this file with a new name, for example, TestConfig.xml.

Open TestConfig.xml in any text editor (I`ve used the VS Code)

SharePoint Online migration 1

I have replaced all true values to false in this example, except SiteUsers and WebLists.

SiteUsers is needed to properly map source site users IDs to the destination users IDs. WebLists is used to save lists.

Since I do not want to save all the lists, but two lists only (Test_List and Test_List_2), I`ll add this requirement to configuration file.

<IncludeFilter>
      <Webs>
        <WebBackupConfig>
          <ServerRelativeUrl>/sites/b</ServerRelativeUrl>
          <Lists>
            <ListBackupConfig>
              <Title>Test_List</Title>
            </ListBackupConfig>
            <ListBackupConfig>
              <Title>Test_List_2</Title>
            </ListBackupConfig>
          </Lists>
        </WebBackupConfig>
      </Webs>
    </IncludeFilter>

ServerRelativeUrl is the relative address of a site with lists.

You can see the values examples below:

Absolute Site Url
Relative Site Url
https://testportal.sharepoint.com
/
https://testportal.sharepoint.com/subsite
/subsite 
https://testportal.sharepoint.com/sites/testsite
/sites/testsite


The final content of the xml file TestConfig.xml:

<?xml version="1.0"?>
<GlobalOptions xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <BackupConfig>
    <Recursive>false</Recursive>
    <SiteGroups>false</SiteGroups>
    <SiteOwners>false</SiteOwners>
    <SiteUsers>true</SiteUsers>
    <WebContentTypes>false</WebContentTypes>
    <WebFields>false</WebFields>
    <WebLists>true</WebLists>
    <WebRoleDefinition>false</WebRoleDefinition>
    <WebRoleAssignments>false</WebRoleAssignments>
    <IncludeFilter>
      <Webs>
        <WebBackupConfig>
          <ServerRelativeUrl>/sites/b</ServerRelativeUrl>
          <Lists>
            <ListBackupConfig>
              <Title>Test_List</Title>
            </ListBackupConfig>
            <ListBackupConfig>
              <Title>Test_List_2</Title>
            </ListBackupConfig>
          </Lists>
        </WebBackupConfig>
      </Webs>
    </IncludeFilter>
  </BackupConfig>
  <RestoreConfig>
  </RestoreConfig>
</GlobalOptions>

Now run cmd.exe (win -> cmd.exe), and go to the folder with the utility Virto Backup & Recovery.

(Using VS Code, you can press F1, type “Create new integrated terminal” and press enter)

Run virtobr.exe with parameters:

virtobr.exe -o backup -s https://testportal.sharepoint.com/sites/b -d c:\TestBackup -u mylogin@testportal.com -p MyP@$sWoRD1 --ConfigPath TestConfig.xml

-o: the type of operation being performed (backup, recovery)

-s: site address (or a folder address for recovery operation)

-d: folder address (the site address for recovery operation), where the backup will be saved (folder will be created automatically with TimeStamp added (e.g. TestBackup_201608251011))

-u: user login to connect to SharePoint

-p: user password to connect to SharePoint

--ConfigPath: The name of configuration file (if you do not specify the name, default Config.xml will be used)

As a result, the folder (such as TestBackup_201608251011) will be created, that will contain the backup files.

You need to run the utility once again with a few changes to restore (move) saved lists to this folder:

virtobr.exe -o recovery -s "c: \ TestBackup_201608251011" -d "https://testportal.sharepoint.com/sites/c" -u mylogin@testportal.com -p MyP@$sWoRD1

Type recovery as the operation (-o). The backup folder address is the source (-s), and the destination (-d) is the address of site collection where I need to restore backup.

After the recovery is done, check the result:

SharePoint Online backup 1
As you can see, we have items with restored Lookup and Person fields.

You can download and use Virto SharePoint Online Backup & Recovery solution and try its 30-days free trial as well.