This is how you migrate the user profile service using PowerShell
– Restore the database from backup
Open PowerShell ISE as administrator and add the snapin
Here you want to restore only the Profile and Social databases. A new synchronization DB will be created automatically.
Add-PSSnapin Microsoft.sharepoint.powershell -ErrorAction SilentlyContinue
Run the following PowerShell and be sure to check the variables
$databaseProfile = 'UPS_ProfileDB'
$databaseSocial = 'UPS_SocialDB'
$databaseSync = 'UPS_Sync'
$applicationPool = 'SharePoint Hosted Services'
New-SPProfileServiceApplication -Name 'User Profile Service' -ApplicationPool $applicationPool -ProfileDBName $databaseProfile -SocialDBName $databaseSocial -ProfileSyncDBName $databaseSync
Run the following PowerShell and check variables
$sa = Get-SPServiceApplication | ?{$_.TypeName -eq 'User Profile Service Application'}
New-SPProfileServiceApplicationProxy -Name ProxyName -ServiceApplication $sa
$proxy = Get-SPServiceApplicationProxy | ?{$_.TypeName -eq 'User Profile Service Application Proxy'}
Add-SPServiceApplicationProxyGroupMember -member $proxy -identity ""