-
- Veteran
- Posts: 528
- Liked: 104 times
- Joined: Sep 17, 2017 3:20 am
- Full Name: Franc
- Contact:
Script to copy settings from periodic copy job to immediate mode copy job.
Hi,
we are adding a new backup repository and also plan to migrate all our copy jobs from periodic mode to immediate mode.
Since going through all the setting of each copy job and adding them to the new copy job is quite a hassle and prone to errors, I'm looking for a method to quickly migrate the settings from our existing periodic copy jobs to immediate mode copy jobs and also modify the target repository.
Is there some sort of script available that does this, so that I don't have to reinvent the wheel myself?
Franc.
we are adding a new backup repository and also plan to migrate all our copy jobs from periodic mode to immediate mode.
Since going through all the setting of each copy job and adding them to the new copy job is quite a hassle and prone to errors, I'm looking for a method to quickly migrate the settings from our existing periodic copy jobs to immediate mode copy jobs and also modify the target repository.
Is there some sort of script available that does this, so that I don't have to reinvent the wheel myself?
Franc.
-
- Veeam Software
- Posts: 21139
- Liked: 2141 times
- Joined: Jul 11, 2011 10:22 am
- Full Name: Alexander Fogelson
- Contact:
Re: Script to copy settings from periodic copy job to immediate mode copy job.
Hi Franc, even if this is not possible with a one-liner, I believe you can create a script to copy the settings one-by-one. Please ask for assistance in the corresponding subforum. Thanks!
-
- Veteran
- Posts: 528
- Liked: 104 times
- Joined: Sep 17, 2017 3:20 am
- Full Name: Franc
- Contact:
Re: Script to copy settings from periodic copy job to immediate mode copy job.
Hi,
Sorry, can you move this topic to the PowerShell forum to prevent duplicate posts?
Sorry, can you move this topic to the PowerShell forum to prevent duplicate posts?
-
- Veteran
- Posts: 1143
- Liked: 302 times
- Joined: Apr 27, 2020 12:46 pm
- Full Name: Natalia Lupacheva
- Contact:
Re: Script to copy settings from periodic copy job to immediate mode copy job.
Hi Franc,
moved your thread to Powershell subforum.
Also, will leave the discussions on switching from periodic to immediate mode here.
Thanks!
moved your thread to Powershell subforum.
Also, will leave the discussions on switching from periodic to immediate mode here.
Thanks!
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: Script to copy settings from periodic copy job to immediate mode copy job.
Hi Franc,
Recently I wrote a cmdlet for that purpose.
Please check my GitHub repo for code and instructions.
Any questions are welcome.
Best regards,
Oleg
Recently I wrote a cmdlet for that purpose.
Please check my GitHub repo for code and instructions.
Any questions are welcome.
Best regards,
Oleg
-
- Veteran
- Posts: 528
- Liked: 104 times
- Joined: Sep 17, 2017 3:20 am
- Full Name: Franc
- Contact:
Re: Script to copy settings from periodic copy job to immediate mode copy job.
Hi Oleg,
thanks! I've tried your script, but it fails on several places in my setup:
After adding a description to the job:
Most of my jobs don't have descriptions and I'm not using WAN-accelerators in any of the jobs.
Franc.
thanks! I've tried your script, but it fails on several places in my setup:
Code: Select all
PS D:\PowershellScripts> Migrate-VBRBackupCopyJob -SourceJob $jobs
Add-VBRViBackupCopyJob : Cannot validate argument on parameter 'Description'. The character length (0) of the argument is too short. Specify an argument with a length that is greater than or
equal to "1", and then try the command again.
At D:\PowershellScripts\Migrate-VBRBackupCopyJob.ps1:35 char:61
+ ... pyJob -Name $migratedName -Description $sourcejob.Description -Backup ...
+ ~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Add-VBRViBackupCopyJob], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.AddVBRViBackupCopyJob
Code: Select all
PS D:\PowershellScripts> $jobs = Get-VBRJob -Name 'Test job'
PS D:\PowershellScripts> Migrate-VBRBackupCopyJob -SourceJob $jobs
Add-VBRViBackupCopyJob : Cannot validate argument on parameter 'SourceAccelerator'. The argument is null. Provide a valid value for the argument, and then try running the command again.
At D:\PowershellScripts\Migrate-VBRBackupCopyJob.ps1:35 char:126
+ ... cription -BackupJob $linkedJobs -SourceAccelerator $sourceWan -Target ...
+ ~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Add-VBRViBackupCopyJob], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationError,Veeam.Backup.PowerShell.Cmdlets.AddVBRViBackupCopyJob
Franc.
-
- Product Manager
- Posts: 9848
- Liked: 2607 times
- Joined: May 13, 2017 4:51 pm
- Full Name: Fabian K.
- Location: Switzerland
- Contact:
Re: Script to copy settings from periodic copy job to immediate mode copy job.
Try to edit the script.
Simply remove everything which is about the wan accelerator.
Example:
Or change this command:
If the parameter is mandatory, use $null as a value instead of the variable
Simply remove everything which is about the wan accelerator.
Example:
Code: Select all
$sourceWan = $sourceJob.FindSourceWanAccelerator()
$targetWan = $sourceJob.FindTargetWanAccelerator()
Code: Select all
Add-VBRViBackupCopyJob -Name $migratedName -Description $sourcejob.Description -BackupJob $linkedJobs -[u][b]SourceAccelerator $sourceWan -TargetAccelerator $targetWan[/b][/u] -Repository $targetRepository -EnableImmediateCopy
Product Management Analyst @ Veeam Software
-
- Veteran
- Posts: 528
- Liked: 104 times
- Joined: Sep 17, 2017 3:20 am
- Full Name: Franc
- Contact:
Re: Script to copy settings from periodic copy job to immediate mode copy job.
Well, it doesn't work in my situation.
First I had to add the '-DirectOperation' parameter to the Add-VBRViBackupCopyJob cmdlet since we aren't using wan accelerators. Also, in some periodic copy jobs, we have included VMs as objects instead of backup jobs. When migrating these kind of jobs using the script it fails since immediate mode jobs only allow Backup jobs to be added, not individual VMs.
When migrating such jobs it errors out with:
So I'm going to migrate the jobs manually.
Thanks!
Franc.
First I had to add the '-DirectOperation' parameter to the Add-VBRViBackupCopyJob cmdlet since we aren't using wan accelerators. Also, in some periodic copy jobs, we have included VMs as objects instead of backup jobs. When migrating these kind of jobs using the script it fails since immediate mode jobs only allow Backup jobs to be added, not individual VMs.
When migrating such jobs it errors out with:
Code: Select all
Add-VBRViBackupCopyJob : Specify BackupJob parameter.
At D:\PowershellScripts\Migrate-VBRBackupCopyJob.ps1:36 char:5
+ Add-VBRViBackupCopyJob -DirectOperation -Name $migratedName -Desc ...
Thanks!
Franc.
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: Script to copy settings from periodic copy job to immediate mode copy job.
Hi Franc,
Updated the script and included cases when description is empty and job is not using wan accelerators.
Thanks,
Oleg
Updated the script and included cases when description is empty and job is not using wan accelerators.
You'll need to specify backup jobs as includes in the UI anyway. It is the only common include type for both backup copy modes.So I'm going to migrate the jobs manually.
Thanks,
Oleg
-
- Veteran
- Posts: 528
- Liked: 104 times
- Joined: Sep 17, 2017 3:20 am
- Full Name: Franc
- Contact:
Re: Script to copy settings from periodic copy job to immediate mode copy job.
Hi Oleg,
thanks! I understand, but since periodic backup copy jobs allow individual VMs to be added as object, whereas immediate mode job don't allow this, not all copy jobs can be migrated. So there need to be a check in the script for that situation also.
Franc.
thanks! I understand, but since periodic backup copy jobs allow individual VMs to be added as object, whereas immediate mode job don't allow this, not all copy jobs can be migrated. So there need to be a check in the script for that situation also.
Franc.
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: Script to copy settings from periodic copy job to immediate mode copy job.
Hi Franc,
Added custom warning listing includes, which won't be added to the target job if their type is unsupported.
Also, added error handling for cases when SourceJob is not of 'BackupSync' type (periodic mode) and backup copy job has already been migrated ( name contains '_migrated' postfix and job type is 'SimpleBackupCopyPolicy').
Hope it helps,
Oleg
Added custom warning listing includes, which won't be added to the target job if their type is unsupported.
Also, added error handling for cases when SourceJob is not of 'BackupSync' type (periodic mode) and backup copy job has already been migrated ( name contains '_migrated' postfix and job type is 'SimpleBackupCopyPolicy').
Hope it helps,
Oleg
-
- Veteran
- Posts: 528
- Liked: 104 times
- Joined: Sep 17, 2017 3:20 am
- Full Name: Franc
- Contact:
Re: Script to copy settings from periodic copy job to immediate mode copy job.
Thanks! Great work! It works, but I'm getting a warning which is a bit misleading:
WARNING: This cmdlet is no longer supported for computer backup jobs. Use "Get-VBRComputerBackupJob" instead.
Although in this case we still need to use 'Get-VBRJob', the warning is more of an informational message. Of course this has nothing to do with your script, but with the powershell cmdlets, but I thought I'd mention it.
WARNING: This cmdlet is no longer supported for computer backup jobs. Use "Get-VBRComputerBackupJob" instead.
Although in this case we still need to use 'Get-VBRJob', the warning is more of an informational message. Of course this has nothing to do with your script, but with the powershell cmdlets, but I thought I'd mention it.
-
- Veeam Software
- Posts: 2010
- Liked: 670 times
- Joined: Sep 25, 2019 10:32 am
- Full Name: Oleg Feoktistov
- Contact:
Re: Script to copy settings from periodic copy job to immediate mode copy job.
No worries. Just add -WarningAction SilentlyContinue to the end of Get-VBRJob parameters to suppress this warning. Thanks!
Who is online
Users browsing this forum: No registered users and 4 guests