PowerShell script exchange
Post Reply
marius roma
Veteran
Posts: 459
Liked: 5 times
Joined: Feb 01, 2012 12:04 pm
Full Name: Mario
Contact:

Rotating folders or VM inside a job

Post by marius roma »

I have a problem that can look quite complex, but I hope there is a solution.
I have many backup and replica jobs based on the contents of folders.
Imagine I have 4 folders:
- VM Italy
- VM France
- VM Greece
- VM Austria
All the jobs use a time window, so if for any reason the job terminates before completing the contents of the latest folders are not processed.
If the same job fails for two times the contents of the latest folders are skipped, and the VM inside the "VM Austria" folder are not processed twice.
I can solve the problem manually by changing the order of the folders inside the job.
Can I create a script that once a day processes all my jobs and rotate the order in which folders are processed, so that the next time the job is executed the order is:
- VM France
- VM Greece
- VM Austria
- VM Italy
and the following time the order is:
- VM Greece
- VM Austria
- VM Italy
- VM France
and so on?
I understand it is complex, but Powershell is so powerfull...
Regards
marius
nefes
Veeam Software
Posts: 643
Liked: 162 times
Joined: Dec 10, 2012 8:44 am
Full Name: Nikita Efes
Contact:

Re: Rotating folders or VM inside a job

Post by nefes »

I can see the solution in removing first object from the job and adding it back. This will move it to the end of the list.
Please check this before implementing in production, it was quickly checked on job with 2 VMs.

Code: Select all

$job = Get-VBRJob -Name <name of your job>
$first = (Get-VBRJobObject -Job $job)[0]
$entity = Find-VBRViEntity -Name $first.Name -Server $first.Location.Split('\')[0]
Remove-VBRJobObject -Objects $first
Add-VBRViJobObject -Job $job -Entities $entity
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests