Rename backup job

PowerShell script exchange

Re: Rename backup job

Veeam Logoby pizzim13 » Thu Oct 31, 2013 3:33 pm

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)
pizzim13
Enthusiast
 
Posts: 86
Liked: 6 times
Joined: Thu Apr 21, 2011 7:37 pm

Re: Rename backup job

Veeam Logoby v.Eremin » Thu Oct 31, 2013 3:57 pm

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.
v.Eremin
Veeam Software
 
Posts: 13290
Liked: 971 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Rename backup job

Veeam Logoby pizzim13 » Mon Nov 04, 2013 9:07 pm

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
        }
    }
pizzim13
Enthusiast
 
Posts: 86
Liked: 6 times
Joined: Thu Apr 21, 2011 7:37 pm

Re: Rename backup job

Veeam Logoby masonit » Fri Jul 24, 2015 8:33 am

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
masonit
Service Provider
 
Posts: 141
Liked: 10 times
Joined: Tue Oct 09, 2012 2:30 pm
Full Name: Magnus Andersson

Re: Rename backup job

Veeam Logoby v.Eremin » Fri Jul 24, 2015 9:33 am

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.
v.Eremin
Veeam Software
 
Posts: 13290
Liked: 971 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Rename backup job

Veeam Logoby AlexL » Thu Sep 17, 2015 2:24 pm

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?
AlexL
Enthusiast
 
Posts: 52
Liked: never
Joined: Tue Aug 24, 2010 8:55 am
Full Name: Alex

Re: Rename backup job

Veeam Logoby v.Eremin » Thu Sep 17, 2015 3:14 pm

The previous workaround doesn't work any longer. So, currently there is no way in PS to rename backup job. Thanks.
v.Eremin
Veeam Software
 
Posts: 13290
Liked: 971 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Rename backup job

Veeam Logoby slide999 » Wed Sep 30, 2015 2:43 pm

I am having the same problem - this is hard to believe. A feature in 7 is not available in 8?
slide999
Lurker
 
Posts: 2
Liked: never
Joined: Thu Sep 25, 2014 9:40 pm
Full Name: Kevin

Re: Rename backup job

Veeam Logoby v.Eremin » Wed Sep 30, 2015 2:54 pm

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.
v.Eremin
Veeam Software
 
Posts: 13290
Liked: 971 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Rename backup job

Veeam Logoby wilkins44 » Wed Feb 01, 2017 4:10 pm

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.
wilkins44
Enthusiast
 
Posts: 28
Liked: 5 times
Joined: Tue Sep 24, 2013 11:17 am
Full Name: Jay Wilkins

Re: Rename backup job

Veeam Logoby v.Eremin » Fri Feb 03, 2017 12:49 pm

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.
v.Eremin
Veeam Software
 
Posts: 13290
Liked: 971 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Previous

Return to PowerShell



Who is online

Users browsing this forum: No registered users and 6 guests