I've put the script below together and Polina asked me to post it here. This will migrate all data from a V2 item-level retention datastore to a V3 snapshot-based retention datastore. We sell our backup packages with x months retention so this was a big thing for the company I work for.
The script will disable any jobs going to the existing repository, migrate user data (mailboxes, OneDrive, sites and archives), then it will migrate site data (SharePoint sites) and finally any group data (mailboxes, archives, OneDrive, sites, group mailboxes and group sites) to the new repository that you've created and specify in the script. Once the data has migrated, the backup jobs will be updated to go to the new repository and then the jobs will be re-enabled. You can then manually remove the old repository and the actual data location where the repository exists. I didn't add this to the script because I wanted to run a backup job to the new repository before deleting the old one, just being cautious
From my experience, there are a few small caveats:
- The migration is a copy, so ensure you have plenty of free disk space before doing this
- You will likely see a lot of warnings, but all of mine were just where user's didn't have archive mailboxes and the warning stated it couldn't move the archive because it didn't exist
Code: Select all
param($OldRepository,$NewRepository)
# Migrate data to new repository
if ($OldRepository -eq $NULL) {
$from = Read-Host "Please type the full name of the old repository"
} else {
$from = $OldRepository
}
if ($NewRepository -eq $NULL) {
$to = Read-Host "Please type the full name of the new repository"
} else {
$to = $NewRepository
}
# Disabling backup jobs
Write-Host "Disabling any jobs going to the repository $from" -ForegroundColor Yellow
$jobs = Get-VBOJob | Where-Object {$_.Repository -like "$from"}
$jobs | Disable-VBOJob
# Migrating data
$repository = Get-VBORepository -Name $from
$destination = Get-VBORepository -Name $to
Write-Host "Starting to migrate user data to the repository $to" -ForegroundColor Yellow
foreach ($user in (Get-VBOEntityData -Type User -Repository $repository)) {
Move-VBOEntityData -From $repository -To $destination -User $user -Mailbox -ArchiveMailbox -OneDrive -Confirm:$false
}
Write-Host "Starting to move SharePoint data to the repository $to" -ForegroundColor Yellow
foreach ($site in (Get-VBOEntityData -Type Site -Repository $repository)) {
Move-VBOEntityData -From $repository -To $destination -Site $site -Confirm:$false
}
Write-Host "Starting to migrate groups data to the repository $to" -ForegroundColor Yellow
foreach ($group in (Get-VBOEntityData -Type Group -Repository $repository)) {
Move-VBOEntityData -From $repository -To $destination -Group $group -Mailbox -ArchiveMailbox -OneDrive -Sites -GroupMailbox -GroupSite -Confirm:$false
}
# Changing jobs to the new repository
Write-Host "Updating the jobs to backup to the repository $to" -ForegroundColor Yellow
foreach ($job in $jobs) {
Set-VBOJob -Job $job -Repository (Get-VBORepository -Name $to)
}
# Enabling jobs
Write-Host "Re-enabling backup jobs" -ForegroundColor Yellow
$jobs | Enable-VBOJob
Write-Host "Migration completed" -ForegroundColor Green
- Save the script to a PS1 file, for example MigrateDatastore.ps1, then from within PowerShell run changing Old Repo for the name of the existing datastore, then change New Repo for the name of your new datastore that's already configured for snapshot-based retention.
Code: Select all
C:\somepath\MigrateDatastore.ps1 -OldRepository Old Repo -NewRepository New Repo
- Run the script itself, it will then ask you type in the name of the repository you are migrating data from, and then it will ask you for the name of the repository you are migrating data to.