PowerShell script exchange
aborigin
Novice
Posts: 5
Liked: never
Joined: May 25, 2012 8:33 am
Full Name: Simon Tomazic
Contact:

Rename backup job

Post by aborigin »

Hello!

I have around 70 backup jobs and I need to rename them by job purpose.

I'm searching for a command that can do that.

Example:

now: job1, job2, job3, job4

after renaming: test_job1, internal_job2, internal_job3, _develop_job4

Thanks,
Simon
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Rename backup job

Post by Sethbartlett »

There is nothing actually supported for renaming the jobs. I could give you some code that will work but it's not pretty whatsoever.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
aborigin
Novice
Posts: 5
Liked: never
Joined: May 25, 2012 8:33 am
Full Name: Simon Tomazic
Contact:

Re: Rename backup job

Post by aborigin »

Every solution that is not clickable would be helpful.

Thanks for help,
Simon
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Rename backup job

Post by Sethbartlett »

Well, I have a semi-easy solution for you. I was working on a new powershell module and it's VERY very alpha but will do what you need :)

http://vpowermodule.googlecode.com/file ... Module.dll

Download this file and place it in your Backup and Replication folder(C:\program files\Veeam\Backup and Replication) and then open up powershell and do:

Code: Select all

Import-Module C:\program Files\Veeam\Backup And Replication\vPowerModule.dll
From here, you can use the following commands to do as you need:

Code: Select all

Get-VPMJob

$Job = Get-VPMJob -name "Name of Job"
$Job.Name = "New Name"
$Job.Save()
The reason I am handing you this DLL is because I already wrote the checking so you cannot accidentally duplicate job names. If I gave you the raw .NET code, you could accidentally rename a bunch of jobs with the same name and that would be a nightmare :wink:

If you run into any problems, let me know on here or @vPowerModule on twitter.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
aborigin
Novice
Posts: 5
Liked: never
Joined: May 25, 2012 8:33 am
Full Name: Simon Tomazic
Contact:

Re: Rename backup job

Post by aborigin »

I face problem right on beginning :)

Code: Select all

PS > import-module "C:\Program Files\Veeam\Backup and Replication\vPowerModule.dll"
Import-Module : Could not load file or assembly 'Lapointe.PowerShell.MamlGenerator, Version=1.0.0.0, Culture=neutral, PublicKeyToken=313d176eae804710
' or one of its dependencies. The system cannot find the file specified.
At line:1 char:14
+ import-module <<<<  "C:\Program Files\Veeam\Backup and Replication\vPowerModule.dll"
    + CategoryInfo          : NotSpecified: (:) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Rename backup job

Post by Sethbartlett » 1 person likes this post

My apologies, like I said, very alpha.

Here is the new link:
http://vpowermodule.googlecode.com/file ... Module.dll

This time it should work fine :) Had to comment out some XML documentation stuff.
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
aborigin
Novice
Posts: 5
Liked: never
Joined: May 25, 2012 8:33 am
Full Name: Simon Tomazic
Contact:

Re: Rename backup job

Post by aborigin »

It works perfectly for me :)

Code: Select all

import-module "C:\Program Files\Veeam\Backup and Replication\vPowerModule.dll"

Foreach ($job in (Get-VBRJob -Name * | Where-Object { $_.GetTargetRepository().name -eq 'DEVELOP' } )) {
	$jobname2rename = $job.Name
	$job2rename = Get-VPMJob -name $jobname2rename
	$job2rename.Name = "DEV_$jobname2rename"
	$job2rename.Save()
}
Thank you for all help.
Sethbartlett
Veteran
Posts: 282
Liked: 26 times
Joined: Nov 10, 2010 6:51 pm
Full Name: Seth Bartlett
Contact:

Re: Rename backup job

Post by Sethbartlett »

No problem at all :)
Skype: Sethbartlett88 - Make sure to label who you are and why you want to add me ;)
Twitter: @sethbartlett
If my post was helpful, please like it. Sometimes twitter is quicker to hit me up if you need me.
foggymtn
Lurker
Posts: 2
Liked: never
Joined: Nov 20, 2012 3:54 pm
Full Name: Rob
Contact:

Re: Rename backup job

Post by foggymtn »

I'm looking to do the same thing. Is there an updated version of the dll for 6.5?

Thanks!
Vitaliy S.
VP, Product Management
Posts: 27377
Liked: 2800 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Rename backup job

Post by Vitaliy S. »

This dll is not officially supported, so I do not believe there is any update to this.
foggymtn
Lurker
Posts: 2
Liked: never
Joined: Nov 20, 2012 3:54 pm
Full Name: Rob
Contact:

Re: Rename backup job

Post by foggymtn »

Sounds good. Thank you for the reply
sidavid
Enthusiast
Posts: 48
Liked: 1 time
Joined: Jan 01, 2006 1:01 am
Contact:

[MERGED] : Rename Job Powershell Veeam 6.5

Post by sidavid »

Hi,
I want to rename job name. I started the script below but it does not work:

Code: Select all

foreach ($Job in Get-VBRJob){
$JobN = $Job.Name
$d= $JobN.substring(0,4)
$n = $JobN.substring(6)
if($JobN.StartsWith("PROD1")){
$JobNew = "JOB1-"+$d+"-DAILY1-"+$n
Write-Host $JobNew 
$Job.Name = $JobNew 
$Job.Save()
}
}
Many thanks
veremin
Product Manager
Posts: 20413
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Rename backup job

Post by veremin »

You have been merged to the existing thread which is concerned with job renaming stuff.

Previously, there has been an option to utilize special .dll provided by Seth Barthlett. However, it seems that this .dll has been written to 6.0 version and can’t be used today.

So, as mentioned above, there is still no supported way how you can rename your job via PS.

Thanks.
Nettkroken
Service Provider
Posts: 5
Liked: never
Joined: Oct 23, 2013 8:44 am
Full Name: Nettkroken AS
Contact:

[MERGED] : Rename Backup Job

Post by Nettkroken »

How do i Rename a Backup job with Powershell, is it possible?
veremin
Product Manager
Posts: 20413
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Rename backup job

Post by veremin »

Quick tests suggest that there is still no way how backup job can be renamed via PS. Though, thanks for the heads-up; highly appreciated.

Thanks.
pizzim13
Enthusiast
Posts: 94
Liked: 6 times
Joined: Apr 21, 2011 7:37 pm
Contact:

Re: Rename backup job

Post by pizzim13 »

Seth helped me out with this a while ago. It works in 6.5 but I haven't "tested" it in 7.x. The code requires that you provide a value for the job name and description. Changing jobs this way does allow you to make dupe job names. Unsupported and no seat belts. Use at your own risk.

Code: Select all

$job = Get-VBRJob -name "Job Name"
$job.info.Update("New Job Name", $job.Description)
[Veeam.Backup.Core.CBackupJob]::Update($job.info)
veremin
Product Manager
Posts: 20413
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Rename backup job

Post by veremin »

It seems to work as expected in version 7. Though, it's still not very straight-forward way to rename job. We will consider how existing commandlets can be improved in one of the next product versions.

Thanks.
pizzim13
Enthusiast
Posts: 94
Liked: 6 times
Joined: Apr 21, 2011 7:37 pm
Contact:

Re: Rename backup job

Post by pizzim13 »

v.Eremin wrote:It seems to work as expected in version 7. Though, it's still not very straight-forward way to rename job. We will consider how existing commandlets can be improved in one of the next product versions.

Thanks.
In the interim I threw the code into a function to make it more understandable and added "seat belts".

Code: Select all

function Rename-VBRBackupJob
    {
    <#
	.SYNOPSIS
        Will rename a backup and/or update description
			
	.EXAMPLE
	  	Rename-VBRBackupJob -JobName "Job" -NewJobName "NewJob"
			
	.EXAMPLE
        Get-VBRJob -Name "Job" | Rename-VBRBackupJob -Description "New description" -NewJobName "NewJob"

	.EXAMPLE
	  	Rename-VBRBackupJob -JobName "Job" -Description "New description"
    #>
    Param
        (
        [Parameter(
        		Mandatory=$false, 
        		ValueFromPipeline=$false,
                ParameterSetName="JobName")
			]
        [ValidateNotNullOrEmpty()]
		[String]$JobName,

        [Parameter(
        		Mandatory=$false, 
        		ValueFromPipeline=$true,
                ParameterSetName="VBRBackupJob")
		]
        [ValidateNotNullOrEmpty()]
        [Veeam.Backup.Core.CBackupJob]$VBRBackupJob,
        
        [Parameter(
        		Mandatory=$false, 
        		ValueFromPipeline=$false,
        		ValueFromPipelineByPropertyName=$false)
		]
        [ValidateNotNullOrEmpty()]
        [String]$NewJobName,

        [Parameter(
        		Mandatory=$false, 
        		ValueFromPipeline=$false,
        		ValueFromPipelineByPropertyName=$false)
		]
        [ValidateNotNullOrEmpty()]
        [String]$Description
        )

    Begin
        {

        }
    Process
        {
        #Validate if $NewJobName is unique
        if (Get-VBRJob -Name $NewJobName)
            {
            throw "Job with name $NewJobName already exists"
            }

        #Get backup job if job name is given
        if ($JobName)
            {
            $VBRBackupJob = Get-VBRJob -Name $JobName
            }
        
        #Keep original job name if one is not specified
        if ($NewJobName)
            {}
        else
            {
            $NewJobName = $VBRBackupJob.Name
            }

        #Keep original job description if one is not specified
        if ($Description)
            {}
        else
            {
            $Description = $VBRBackupJob.Description
            }

        #Updating name and description
        $VBRBackupJob.info.Update($NewJobName, $Description)
        [Veeam.Backup.Core.CBackupJob]::Update($VBRBackupJob.info)

        }
    End
        {
        Get-VBRJob -Name $NewJobName
        }
    }
masonit
Service Provider
Posts: 327
Liked: 23 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Maso
Contact:

Re: Rename backup job

Post by masonit »

When renaming a backupjob it's folder and backup files does not get renamed on the repository. Is it possible to rename them as well to get a unified name?

\Masonit
veremin
Product Manager
Posts: 20413
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Rename backup job

Post by veremin »

Nope, you can rename job and apply new name convention to upcoming backup files, starting from the next full backup. However, those files that are already present inside the given folder will stay intact. Thanks.
AlexL
Service Provider
Posts: 105
Liked: 7 times
Joined: Aug 24, 2010 8:55 am
Full Name: Alex
Contact:

Re: Rename backup job

Post by AlexL »

I've made some scripts using the code from 2013 that worked fine with v7 but gives an error with v8.
How do I rename a job in powershell with v8?
veremin
Product Manager
Posts: 20413
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Rename backup job

Post by veremin »

The previous workaround doesn't work any longer. So, currently there is no way in PS to rename backup job. Thanks.
slide999
Novice
Posts: 5
Liked: never
Joined: Sep 25, 2014 9:40 pm
Full Name: Kevin
Contact:

Re: Rename backup job

Post by slide999 »

I am having the same problem - this is hard to believe. A feature in 7 is not available in 8?
veremin
Product Manager
Posts: 20413
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Rename backup job

Post by veremin »

It has not been a feature, but rather an undocumented workaround loading an assembly and making use of internal methods. The structure of latter was changed in version 8, thus, the previously existing workaround doesn't apply any longer.

However, we have this request tracked and plan to introduce corresponding commandlets in one of the next product versions.

Thanks.
wilkins44
Enthusiast
Posts: 32
Liked: 5 times
Joined: Sep 24, 2013 11:17 am
Full Name: Jay Wilkins
Contact:

Re: Rename backup job

Post by wilkins44 »

Just curious, but has there been any updates to this? Having a rename command in V9.5 would be extremely helpful.

My goal is to use Get-VBRJob then copy that job, rename it, and enable it.
veremin
Product Manager
Posts: 20413
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Rename backup job

Post by veremin »

Try this workaround and see whether it helps. However, use it on your own risk:

Code: Select all

Asnp VeeamPSSnapin
$Job = Get-VBRJob -Name "Current name"
$Job.info.CommonInfo.Name = "New name"
$Job.Update()
Thanks.
jjlethiers
Service Provider
Posts: 13
Liked: 1 time
Joined: Apr 11, 2016 9:55 am
Full Name: Jean-Jacques Lethiers
Contact:

Re: Rename backup job

Post by jjlethiers »

Hi guys,
I am trying to edit the description field of existing backup copy jobs in PS.
Any idea how to do it with 9.5u4?
Regards,
JJ
Lucas_H
Influencer
Posts: 17
Liked: 4 times
Joined: Nov 16, 2018 3:14 pm
Full Name: Lucas HELLMANN
Location: Lyon, FRANCE
Contact:

Re: Rename backup job

Post by Lucas_H »

Hi,

You can look at this forum post for a way to change the description : powershell-f26/change-job-description-f ... t8245.html

Cheers,
Lucas H
masonit
Service Provider
Posts: 327
Liked: 23 times
Joined: Oct 09, 2012 2:30 pm
Full Name: Maso
Contact:

Re: Rename backup job

Post by masonit »

Hi!

Still no supported way to rename backup and backup copy job with PS?

\Magnus
oleg.feoktistov
Veeam Software
Posts: 2010
Liked: 670 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Rename backup job

Post by oleg.feoktistov »

Hi Magnus,

Depends on the job type. You can set Name and Description for all the job types, that have dedicated Set cmdlets. For example, this is available for agent management jobs or NAS. Since in v12 backup copy job becomes multiplatform, we also plan to introduce new cmdlets for it making renaming available. So, we are getting there step by step.
No renaming options for primary backup jobs of VMware or Hyper-V types though. We would need new dedicated cmdlets for them to avoid dealing with legacy and core code.
They are also planned for one of vNext versions.

Best regards,
Oleg
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests