Maintain control of your Microsoft 365 data
Post Reply
Bjoern_ch
Service Provider
Posts: 45
Liked: 16 times
Joined: Sep 09, 2022 12:22 pm
Full Name: Bjoern
Location: Zurich
Contact:

remove deleted sites & teams from job with remove-vbobackupitem

Post by Bjoern_ch »

Hi veeam team,

we have a customer with a large sp/teams environment which we splitted into 47 jobs/repos and 12 proxies. each job contains around 3500 objects.
To achieve this we used a script from veeamhub (vb/jobmanager). It worked and script now runs daily. When new teams/sites are created they are added to a backup job.
But unfortunately deleted sites/teams are not removed from the job and therefore create an error (404 - not found).

How can I remove deleted teams and sites from the backupjobs using powershell?

In the powershell reference I found this:
"
Remove-VBOBackupItemExample 1. Removing Backup Item by Name
This example shows how to remove a Microsoft Exchange or Microsoft SharePoint object from the scope of the TestJob backup job even if this object is no longer available in Microsoft organization.
$job = Get-VBOJob -Name "TestJob"

$item = Get-VBOBackupItem -Job $job -Name "ObjectToRemove"

Remove-VBOBackupItem -Job $job -BackupItem $item
"
https://helpcenter.veeam.com/docs/vbo36 ... tml?ver=70

Well, i tried it but this was not a good idea :-(
Actually, I tested it with one item (a team which had a very long name). It worked fine.
But I have around 10K teams/sites which I want to remove from my 47 jobs. I have a .csv (Identity,DisplayName,Name,ExchangeGuid,Guid) which contains all deleted teams/sites.
So, i created a small script with the example provided in the veeam ps reference:

Code: Select all

$backupItems = Import-Csv -Path "C:\Scripts\deletedsitesteams.csv"
foreach ($itemEntry in $backupItems) {
    $itemName = $itemEntry.DisplayName
    # Remove backup item from job
    $job = Get-VBOJob -Name "SharePointTeams-001"
    $item = Get-VBOBackupItem -Job $job -Name $itemName
    Remove-VBOBackupItem -Job $job -BackupItem $item}
Because the 10K deleted sites/teams are spread over the 47 jobs I expected around 98% error messages. Not good for performance but it should work i thought.
When script was finished I noticed that were only 10 teams left in job. It should have been around 3200.
What happened? It turned out that "Get-vbobackupitem" can return more than 1 item. Which is very bad. I checked csv and archive.powershell logs and there were many teams with DisplayNames like "BA" or "test".
If you have e.g. 5 teams: test, test1, test2, test3, test4 and want only to remove the team "test" then unfortunately all 5 teams are removed from the job if you do this with Powershell. In my case the string/team DisplayName "BA" removed nearly everything from the job. This was quite a mess.

Does anyone have a solution for this? How can I remove deleted sites/teams from a backupjob automatically?

Any help/hint is appreciated.

Bjoern
Mildur
Product Manager
Posts: 8735
Liked: 2294 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: remove deleted sites & teams from job with remove-vbobackupitem

Post by Mildur »

Hello Björn

I can see the same behavior in my lab. Unfortunately -name filter is a wildcard filter.
Let me check that with our teams.

Best,
Fabian
Product Management Analyst @ Veeam Software
Bjoern_ch
Service Provider
Posts: 45
Liked: 16 times
Joined: Sep 09, 2022 12:22 pm
Full Name: Bjoern
Location: Zurich
Contact:

Re: remove deleted sites & teams from job with remove-vbobackupitem

Post by Bjoern_ch » 1 person likes this post

Hi Fabian,

thanks for your reply.
Also asked support and they told me that a design change is already planned.
But solution is actually quite simple. :-) Just use an equal operator like this:

Code: Select all

# Load the CSV file
$backupItems = Import-Csv -Path "C:\Scripts\AllUnifiedGroupsWithoutManagerMembers-test1.csv"
$job = Get-VBOJob -Name "SharePointTeams-003"

# Loop through each entry in the CSV
foreach ($itemEntry in $backupItems) {
    # Retrieve the name from the current CSV row
    $itemName = $itemEntry.DisplayName
    
    # Remove backup item from job
    $item = get-vbobackupitem -job $job | Where {$_.Site.Name -eq $itemName}
    Remove-VBOBackupItem -Job $job -BackupItem $item
    $item = get-vbobackupitem -job $job | Where {$_.Team.DisplayName -eq $itemName}
    Remove-VBOBackupItem -Job $job -BackupItem $item
}
Best regards,
Bjoern
Mildur
Product Manager
Posts: 8735
Liked: 2294 times
Joined: May 13, 2017 4:51 pm
Full Name: Fabian K.
Location: Switzerland
Contact:

Re: remove deleted sites & teams from job with remove-vbobackupitem

Post by Mildur »

Hi Bjoern

I'm glad you could find a way with our support.
Last week I talked to the Team/QA and we decided to update the behavior of the name parameter in one of our future version.
The plan is to get rid of the "wildcard" behavior and instead use "equals".

Best,
Fabian
Product Management Analyst @ Veeam Software
Post Reply

Who is online

Users browsing this forum: Semrush [Bot] and 16 guests