User Data Backup in OSD: Windows 7 to 10 Migration

Currently, the University of Minnesota is working on our Windows 7 to 10 migration.  One of the key risks identified is that user data could be lost during the transition.  Our current process involves our desktop support technicians manually backing up user data, then running a wipe and reload task sequence followed by a manual restore of user data.  This manually intensive process is also not very consistent.

We have decided to take a two-pronged approach to dealing with user data in such a way as to keep our data loss risk as low as possible.  We will be using USMT in our task sequence to backup and restore user data along with a "just in case" complete disk image using MDT to create a WIM of the hard drive.

Using USMT

User State Migration Toolkit is fairly easy to get up and running with in any task sequence.

Before beginning to leverage USMT you’ll need to set up a state migration point. We needed to reconfigure how our boundaries were setup to leverage IP boundaries to make sure the migration point was available to the proper devices. I’d recommend reading through the Microsoft documentation on state migration as it’s a wealth of knowledge about setting up a state migration point.

Once you have your state migration point setup and working you’ll need to create a task sequence that is able to leverage USMT. We decided to do USMT in WinPE because it made everything much simpler and ran faster. There are some quirks to things that migrate offline vs online and they’re also worth considering as you build your task sequence.

Since we’re doing a re-image with the task sequence if we start in windows we want to make sure Bitlocker is suspended prior to rebooting into WinPE. We do this using the built in Disable Bitlocker step in SCCM task sequences and have it target the current operating system drive. It’s also set to continue on error to avoid some issues we had on test devices and haven’t had issues in production with this configuration.

Capturing User State

After disabling Bitlocker from Windows restart the device into WinPE and the first USMT step is to Request State Store which will look at what state store’s are assigned to the device and fail if none are found. This step should fail on error. We request the store to Capture state from the computer and try 5 times with a 60 second delay and to fail over to the network access account if the computer account fails.

Now that we have a state store we can capture our user state using the Capture User State step. You’ll need to point it to the built in User State Migration Tool for Windows package. If you don’t have this or need to generate a new package there is a built in template for it in the package wizard.

We use four files, MigApp.xml and MigUser.xml are both the standard built in configuration files provided by USMT and should already be in your USMT package. We’ve also built two custom USMT files. See below for their contents and a brief description of what they’re doing. Along with the files we’ve enabled verbose logging, skipping files that use EFS and to copy the files using offline/win-pe mode. If you’re not using offline mode you’ll want to not check this box and/or check the VSS box depending on your own scenarios and based on your own testing.

OITCM-CustomeExclude.xml as shown below is designed to not include the computer certificate in the backup (the SkipMachineCerts) section which caused issues early on in testing with some devices.

We’ve also excluded specific user data locations where we didn’t want installers and/or other files coming through. We also decided to not include any startup or start menu shortcuts as this brought over all sorts of shortcuts that were broken on the device after re-imaging.

<?xml version="1.0" encoding="UTF-8"?&gt;
<migration urlid="http://www.microsoft.com/migration/1.0/migxmlext/customExclude"&gt;
   <component type="Documents" context="System"&gt;
      <displayName&gt;SkipMachineCerts</displayName&gt;
      <role role="Data"&gt;
         <rules&gt;
            <include&gt;
               <objectSet&gt;
                  <pattern type="Registry"&gt;HKLM\SOFTWARE\Microsoft\SystemCertificates\My\Certificates\*[*]</pattern&gt;
               </objectSet&gt;
            </include&gt;
			<unconditionalExclude&gt;
               <objectSet&gt;
                  <pattern type="Registry"&gt;HKLM\SOFTWARE\Microsoft\SystemCertificates\My\Certificates\*[*]</pattern&gt;
               </objectSet&gt;
            </unconditionalExclude&gt;
         </rules&gt;
      </role&gt;
   </component&gt;
   
   <!-- This component EXCLUDES the following User specific stuff--&gt;
   <component type="System" context="user"&gt;
       <displayName _locID="miguser.User_Exclusions"&gt;User Exclusions</displayName&gt;
       <role role="Data"&gt;
           <rules&gt;
               <unconditionalExclude&gt;
                   <objectSet&gt;

                   <!-- exclude blank links on the desktop--&gt;    
                   <pattern type="File"&gt;%CSIDL_DESKTOP%\* [*.msi]</pattern&gt;
                   <pattern type="File"&gt;%CSIDL_DESKTOP%\* [*.exe]</pattern&gt;
                   <pattern type="File"&gt;%CSIDL_DESKTOP%\* [*.lnk]</pattern&gt;
                   <pattern type="File"&gt;%CSIDL_DESKTOP%\* [*.lnk2]</pattern&gt;

                   <pattern type="File"&gt;%CSIDL_DESKTOPDIRECTORY%\* [*.msi]</pattern&gt;
                   <pattern type="File"&gt;%CSIDL_DESKTOPDIRECTORY%\* [*.exe]</pattern&gt;
                   <pattern type="File"&gt;%CSIDL_DESKTOPDIRECTORY%\* [*.lnk]</pattern&gt;
                   <pattern type="File"&gt;%CSIDL_DESKTOPDIRECTORY%\* [*.lnk2]</pattern&gt;



                   <pattern type="File"&gt;%CSIDL_DEFAULT_DESKTOP%\* [*.msi]</pattern&gt;
                   <pattern type="File"&gt;%CSIDL_DEFAULT_DESKTOP%\* [*.exe]</pattern&gt;
                   <pattern type="File"&gt;%CSIDL_DEFAULT_DESKTOP%\* [*.lnk]</pattern&gt;
                   <pattern type="File"&gt;%CSIDL_DEFAULT_DESKTOP%\* [*.lnk2]</pattern&gt;


                   <pattern type="File"&gt;%CSIDL_DEFAULT_PROGRAMS%\* [*]</pattern&gt;
                   <pattern type="File"&gt;%CSIDL_DEFAULT_STARTMENU%\* [*]</pattern&gt;
                   <pattern type="File"&gt;%CSIDL_DEFAULT_STARTUP%\* [*]</pattern&gt;
                   <pattern type="File"&gt;%CSIDL_PROGRAMS%\* [*]</pattern&gt;   		                 
                   <pattern type="File"&gt;%CSIDL_STARTMENU%\* [*]</pattern&gt;
                   <pattern type="File"&gt;%CSIDL_STARTUP%\* [*]</pattern&gt;

                   </objectSet&gt;
               </unconditionalExclude&gt;
           </rules&gt;
       </role&gt;
   </component&gt;

   <!-- This component EXCLUDES the following shared User specific stuff--&gt;
   <component type="System" context="System"&gt;
       <displayName _locID="miguser.Shared_User_Exclusions"&gt;Shared User Exclusions</displayName&gt;
       <role role="Data"&gt;
           <rules&gt;
               <unconditionalExclude&gt;
                   <objectSet&gt;


                   <pattern type="File"&gt;%CSIDL_COMMON_DESKTOPDIRECTORY%\* [*.msi]</pattern&gt;
                   <pattern type="File"&gt;%CSIDL_COMMON_DESKTOPDIRECTORY%\* [*.exe]</pattern&gt;
                   <pattern type="File"&gt;%CSIDL_COMMON_DESKTOPDIRECTORY%\* [*.lnk]</pattern&gt;
                   <pattern type="File"&gt;%CSIDL_COMMON_DESKTOPDIRECTORY%\* [*.lnk2]</pattern&gt;



                   <pattern type="File"&gt;%CSIDL_COMMON_PROGRAMS%\* [*]</pattern&gt;
                   <pattern type="File"&gt;%CSIDL_COMMON_STARTMENU%\* [*]</pattern&gt;
                   <pattern type="File"&gt;%CSIDL_COMMON_STARTUP%\* [*]</pattern&gt;

                   <pattern type="File"&gt;%CSIDL_PROGRAMS%\* [*]</pattern&gt;   		                 
                   <pattern type="File"&gt;%CSIDL_STARTMENU%\* [*]</pattern&gt;
                   <pattern type="File"&gt;%CSIDL_STARTUP%\* [*]</pattern&gt;

                   </objectSet&gt;
               </unconditionalExclude&gt;
           </rules&gt;
       </role&gt;
   </component&gt;
</migration&gt;

In our OITCM-CustomMigrations.xml file as shown below we’ve set up custom migrations for several highly used applications within our environment. I’ve also left in a very specific example of how to migrate a programdata folder as that was also helpful for us. We have Firefox, Thunderbird, Chrome, Perceptive Content, Downloads, and Custom File Extensions added into the migration.

<?xml version="1.0" encoding="UTF-8"?&gt;
<migration urlid="http://www.microsoft.com/migration/1.0/migxmlext/oitcmcustom"&gt;
    <!-- Start Firefox Migration --&gt;
    <component type="Documents" context="User"&gt;
        <displayName&gt;Mozilla Migration</displayName&gt;
        <role role="Data"&gt;
            <detects&gt;
                <detect&gt;
                    <condition&gt;MigXmlHelper.DoesObjectExist("File","%CSIDL_APPDATA%\Mozilla")</condition&gt;
                </detect&gt;
            </detects&gt;
            <rules&gt;
                <include filter='MigXmlHelper.IgnoreIrrelevantLinks()'&gt;
                    <objectSet&gt;
                        <pattern type="File"&gt;%CSIDL_APPDATA%\Mozilla\* [*]</pattern&gt;
                    </objectSet&gt;
                </include&gt;
            </rules&gt;
        </role&gt;
    </component&gt;

    <component type="Documents" context="User"&gt;
        <displayName&gt;Thunderbird Migration</displayName&gt;
        <role role="Data"&gt;
            <detects&gt;
                <detect&gt;
                    <condition&gt;MigXmlHelper.DoesObjectExist("File","%CSIDL_APPDATA%\Thunderbird")</condition&gt;
                </detect&gt;
            </detects&gt;
            <rules&gt;
                <include filter='MigXmlHelper.IgnoreIrrelevantLinks()'&gt;
                    <objectSet&gt;
                        <pattern type="File"&gt;%CSIDL_APPDATA%\Thunderbird\* [*]</pattern&gt;
                    </objectSet&gt;
                </include&gt;
            </rules&gt;
        </role&gt;
    </component&gt;
    <!-- End Firefox Migration --&gt;

    <!-- Start Chrome Migration --&gt;
    <component type="Documents" context="User"&gt;
        <displayName&gt;Google Chrome Migration</displayName&gt;
        <role role="Data"&gt;
            <detects&gt;
                <detect&gt;
                    <condition&gt;MigXmlHelper.DoesObjectExist("File","%CSIDL_LOCAL_APPDATA%\Google\Chrome")</condition&gt;
                </detect&gt;
            </detects&gt;
            <rules&gt;
                <include filter='MigXmlHelper.IgnoreIrrelevantLinks()'&gt;
                    <objectSet&gt;
                        <pattern type="File"&gt;%CSIDL_LOCAL_APPDATA%\Google\Chrome\* [*]</pattern&gt;
                    </objectSet&gt;
                </include&gt;
            </rules&gt;
        </role&gt;
    </component&gt;
    <!-- End Chrome Migration --&gt;

    <!-- Start ImageNow/Perceptive Content Migration --&gt;
    <component type="Documents" context="System"&gt;
        <displayName&gt;Perceptive Content Migration</displayName&gt;
        <role role="Data"&gt;
            <detects&gt;
                <detect&gt;
                    <condition&gt;MigXmlHelper.DoesObjectExist("File","%CSIDL_COMMON_APPDATA%\ImageNow")</condition&gt;
                </detect&gt;
            </detects&gt;
            <rules&gt;
                <include filter='MigXmlHelper.IgnoreIrrelevantLinks()'&gt;
                    <objectSet&gt;
                        <pattern type="File"&gt;%CSIDL_COMMON_APPDATA%\ImageNow\* [*]</pattern&gt;
                    </objectSet&gt;
                </include&gt;
            </rules&gt;
        </role&gt;
    </component&gt;
    <!-- End ImageNow/Perceptive Content Migration --&gt;

    <!-- Start ImageNow/Perceptive Content Backup Migration --&gt;
    <component type="Documents" context="System"&gt;
        <displayName&gt;Perceptive Content Backup Migration</displayName&gt;
        <role role="Data"&gt;
            <detects&gt;
                <detect&gt;
                    <condition&gt;MigXmlHelper.DoesObjectExist("File", "%CSIDL_COMMON_APPDATA%\ImageNow722-Archive")</condition&gt;
                </detect&gt;
            </detects&gt;
            <rules&gt;
                <include filter='MigXmlHelper.IgnoreIrrelevantLinks()'&gt;
                    <objectSet&gt;
                        <pattern type="File"&gt;%CSIDL_COMMON_APPDATA%\ImageNow722-Archive\* [*]</pattern&gt;
                    </objectSet&gt;
                </include&gt;
            </rules&gt;
        </role&gt;
    </component&gt;
    <!-- End ImageNow/Perceptive Content Backup Migration --&gt;

    <!-- Start Downloads Migration --&gt;
    <component type="Documents" context="User"&gt;
        <displayName&gt;My Downloads</displayName&gt;
        <paths&gt;
            <path type="File"&gt;%FOLDERID_DOWNLOADS%</path&gt;
        </paths&gt;
        <role role="Data"&gt;
            <detects&gt;
                <detect&gt;
                    <condition&gt;MigXmlHelper.DoesObjectExist("File","%FOLDERID_DOWNLOADS%")</condition&gt;
                </detect&gt;
            </detects&gt;
            <rules&gt;
                <include filter='MigXmlHelper.IgnoreIrrelevantLinks()'&gt;
                    <objectSet&gt;
                        <pattern type="File"&gt;%FOLDERID_DOWNLOADS%\* [*]</pattern&gt;
                    </objectSet&gt;
                </include&gt;
                <merge script="MigXmlHelper.DestinationPriority()"&gt;
                    <objectSet&gt;
                        <pattern type="File"&gt;%FOLDERID_DOWNLOADS% [desktop.ini]</pattern&gt;
                    </objectSet&gt;
                </merge&gt;
            </rules&gt;
        </role&gt;
    </component&gt;
    <!-- End Downloads Migration --&gt;

    <!-- Start known file extensions --&gt;
    <component type="Documents" context="System"&gt;
        <displayName&gt;Custom File Extensions</displayName&gt;
        <role role="Data"&gt;
            <rules&gt;
                <include&gt;
                    <objectSet&gt;
                        <script&gt;MigXmlHelper.GenerateDrivePatterns ("* [*.pdf]", "Fixed")</script&gt;
                    </objectSet&gt;
                </include&gt;
                <exclude&gt;
                    <objectSet&gt;
                        <pattern type="File"&gt;%PROFILESFOLDER%\* [*]</pattern&gt;
                        <pattern type="File"&gt;%CSIDL_WINDOWS%\* [*]</pattern&gt;
                        <pattern type="File"&gt;%CSIDL_PROGRAM_FILES%\* [*]</pattern&gt;
						<pattern type="File"&gt;%CSIDL_COMMON_APPDATA%\Johnson Controls\* [*]</pattern&gt;
                        <!--We are trying to remove system files from other windows installation on the same machine--&gt;
                        <!--This is the best guess we can come up with, in case of these folder name localized, we might not be
                         to do whatever we have intended here--&gt;
                        <script&gt;MigXmlHelper.GenerateDrivePatterns ("\Program Files\* [*]", "Fixed")</script&gt;
                        <script&gt;MigXmlHelper.GenerateDrivePatterns ("\Winnt\* [*]", "Fixed")</script&gt;
                        <script&gt;MigXmlHelper.GenerateDrivePatterns ("\Windows\* [*]", "Fixed")</script&gt;
                    </objectSet&gt;
                </exclude&gt;
            </rules&gt;
        </role&gt;
    </component&gt;
    <!-- End known file extensions --&gt;
</migration&gt;

Finally, once you’re all ready to go, simply add a Release State Store step and you’re done!

Restoring User State

Restoring user state is much like capturing, we need both a Request State Store step before the restore and a Release State Store added after the restore. When it comes to configuring the Restore User State step, we again point it at our USMT package and then we selected to Restore all captured user profiles with standard options. We didn’t need any additional customization on this section.

WIM Backup

To capture a WIM of the device during the task sequence as a backup you’ll need to get MDT integration if you don’t already have it. There’s good info on this on the Microsoft docs page. You’ll also need an MDT toolkit package and this guide walks you through the basics of setting up your first MDT enabled task sequence.

WIM Capture

Firstly, add a Use Microsoft Deployment Toolkit Package step if it’s not already in your task sequence. It should point to the MDT package you created either through the task sequence wizard or the package wizard.

The second step is to add a Gather step which will pull settings off the device which are then used by MDT for its various features. We set it up to just Gather only local data (do not process rules) as we didn’t need anything custom or fancy, just some info about the drives. required by one of the MDT scripts we’ll be calling later on.

The third step is to set the task sequence variable ComputerBackupLocation to the location you want the WIM stored. This can/should be a network drive. This is a variable used by the MDT backup script to generate the WIM.

Finally we come to the stage where we can capture the WIM. We’ll need a Run Command Line step with the command cscript.exe "%DeployRoot%\Scripts\ZTIBackup.wsf" which will run the MDT WIM backup script.

And there you have it! That’s how we’re using USMT as well as MDT to capture user state and full disk images during a task sequence.

WIM Restore

If you’re looking to restore the WIM you’ve just captured, below are the steps. I would say this is not a 100% guaranteed restore and there will likely be issues. We’ve had good luck with it internally so far however.

Things to Gather Before Beginning

  • WinPE Boot Media
  • Windows 7 Installation Media
  • External drive or network share with the WIM

Steps

  1. Boot into a WinPE image. The SCCM boot media will suffice for this. You’ll need to use F8 to open a command prompt and then run the diskpart command to build the appropriate partition table.
    • select disk 0 (select the main disk for the system)
    • Clean
    • Create partition primary size=300
    • Format quick fs=ntfs label=”System”
    • Assign letter=”S”
    • Active
    • Create partition primary
    • Format quick fs=ntfs label=”Windows”
    • Assign letter=”C”
    • Exit
  2. Now you’ll need to use the dism tool to apply the WIM image to use the drive.
    • If you’ve stored the WIM on a network share use the net use y: \path\to\share method to mount the network share as a drive.
    • Commands to run:
      • dism /apply-image /imagefile:y:\path\to\image.wim /index:1 /ApplyDir:C:\
      • The index can be found using the dism /Get-ImageInfo /imagefile:y:\path\to\image.wim command. This is the location within the WIM where the OS is stored. You may have additional images for other partitions of the drive.
  3. Now you’ll need to boot into Windows 7 installation media and choose the recovery option.
  4. Choose the option to mark partitions as active.
    • Diskpart commmands:
      • select disk disk
      • select partition partition
      • assign
      • active
  5. Run the following commands:
    • bootrec /fixboot
    • bootrec /scanos
    • bootrec /fixmbr
    • bootrec /rebuildbcd
  6. Restart the computer and re-enter the Windows 7 recovery mode on the install media
  7. Choose the repair Windows 7 option.
  8. Choose the fix startup option.
  9. Restart the computer and login as a local admin account.
  10. Unbind and rebind the computer.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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