Maintain control of your Microsoft Office 365 email data
Post Reply
ScottyP89
Service Provider
Posts: 18
Liked: 4 times
Joined: Jan 02, 2019 4:13 pm
Full Name: Scott Prudence
Contact:

Changing datastores from item-level retention to snapshot-based retention

Post by ScottyP89 » Apr 18, 2019 2:52 pm 3 people like this post

Hi All,

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
There are two ways you can use this script:
  1. Save the script to a PS1 file, for example MigrateDatastore.ps1, then from within PowerShell run

    Code: Select all

    C:\somepath\MigrateDatastore.ps1 -OldRepository Old Repo -NewRepository New Repo
    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.
  2. 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.
Hopefully some of you will find this useful!

Mike Resseler
Product Manager
Posts: 5749
Liked: 613 times
Joined: Feb 08, 2013 3:08 pm
Full Name: Mike Resseler
Location: Belgium
Contact:

Re: Changing datastores from item-level retention to snapshot-based retention

Post by Mike Resseler » Apr 19, 2019 5:22 am

This is great stuff ScottyP89!

Thanks for this, many people her are going to be very happy with it!

cheers
Mike

jandrewartha
Influencer
Posts: 19
Liked: 1 time
Joined: Feb 13, 2017 1:49 am
Contact:

Re: Changing datastores from item-level retention to snapshot-based retention

Post by jandrewartha » Oct 12, 2019 3:04 am

So I've used this script, it took several months for about 9TB of data (at least it gracefully restarted after monthly patch reboots). I have a few questions though:
  1. The documentation for Move-VBOEntityData says "This cmdlet does not support migration of organization entities data between repositories with different types of retention policy." but it worked so ?
  2. The old repository is still taking up all the space, although when I run the command again it completes basically instantly. Does it not shrink the database after removing the data?
  3. Relatedly, when I go to remove the repository from the manager, it says I may lose access to old restore points. Is there a way I can check if all the old restore points have been moved across? Or can I remove it, check the restore points, and then re-add it if not?

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 4 guests