PowerShell script exchange
nd39475
Enthusiast
Posts: 61 Liked: 7 times
Joined: May 05, 2016 6:28 pm
Full Name: n d
Contact:
Post
by nd39475 » Nov 21, 2019 9:01 pm
this post
I made this nifty script to give me a rundown of our jobs and RP's but i have some jobs reporting that there are no RP's when in fact they do exist. It seems that when a backupCopy is renamed, the cmd-let Get-VBRRestorePoint can no longer find the RP's.
Code: Select all
$vbrback= Get-VBRBackup -Name "someNameHere"
$restorepoints=($vbrback | Get-VBRRestorePoint)
Write-Output "Count of RP`'s found: $($restorepoints.Count)"
The above snippet shows zero RP's for a BackupCopy that was renamed. but when i use the Console it shows them. the issue seems to be that the target folder name does not match the backupCopy job name.
is there any solution to such?
Code: Select all
Add-PSSnapin VeeamPSSnapIn
Function PrintRestorePoints ($jobs) {
foreach ($job in $jobs) {
$jName = $job.Name
$jSched=($job|Get-VBRJobScheduleOptions)
#$jObject= ($job|Get-VBRJobObject)
$jOptions=($job|Get-VBRJobOptions)
Write-Output "Job: $jName"
if ($job.IsScheduleEnabled) {
if ($jSched.OptionsContinuous.Enabled) { Write-Output "Job Type: Continuous" } else { Write-Output "RetainCycles: $($jOptions.Options.RootNode.RetainCycles)" }
if ($jSched.OptionsDaily.Enabled) { Write-Output "Daily Enabled" }
if ($jSched.OptionsMonthly.Enabled) { Write-Output "Monthly Enabled" }
if ($jSched.OptionsPeriodically.Enabled) { Write-Output "Periodical Enabled" }
} else { Write-Output "Job Type: Manual"}
Write-Output "RetentionPolicyType: $($jOptions.GenerationPolicy.RetentionPolicyType)"
Write-Output "SimpleRetentionRestorePoints: $($jOptions.GenerationPolicy.SimpleRetentionRestorePoints)"
#Write-Output "ActualRetentionRestorePoints: $($jOptions.GenerationPolicy.ActualRetentionRestorePoints)""
$vbrback= Get-VBRBackup -Name $job.LogNameMainPart
Write-Output "Count of VM's: $($vbrback.VmCount)"
#Write-Output "WeeklyBackupDayOfWeek $($jOptions.GenerationPolicy.WeeklyBackupDayOfWeek)"
#Write-Output "WeeklyBackupTime $($jOptions.GenerationPolicy.WeeklyBackupTime)"
$restorepoints=($vbrback | Get-VBRRestorePoint)
Write-Output "Count of RP`'s found: $($restorepoints.Count)"
if ($restorepoints.Count) {
$restorepoints | sort-object vmname,CreationTime | format-table -Property vmname,CreationTime -AutoSize -HideTableHeaders
} else {write-Output "`n"}
#foreach ($rp in $restorepoints) {
#$rp | Select-Object vmname,CreationTime | ft -auto
#write-Output $($rp.VmName) $($rp.CreationTime)
#}
}
} #end Function
Connect-VBRServer -server MYSERVER -port 9392
clear
$jobs = ( Get-VBRJob | where {$_.Name -like "Library1*Copy*"} | Sort-Object -Property Name)
PrintRestorePoints ($jobs) | Tee-Object Library1_RP_Tallies.txt
$jobs = ( Get-VBRJob | where {$_.Name -like "Library2*Copy*"} | Sort-Object -Property Name)
PrintRestorePoints ($jobs) | Tee-Object Library2_RP_Tallies.txt
$jobs = ( Get-VBRJob | where {$_.Name -notlike "*Copy*"} | Sort-Object -Property Name)
PrintRestorePoints ($jobs) | Tee-Object VeeamServ_RP_Tallies.txt
Disconnect-VBRServer
nd39475
Enthusiast
Posts: 61 Liked: 7 times
Joined: May 05, 2016 6:28 pm
Full Name: n d
Contact:
Post
by nd39475 » Nov 21, 2019 9:12 pm
this post
Crap, it's even worse than i thought, i just noticed
Code: Select all
Write-Output "Count of VM's: $($vbrback.VmCount)"
produces nothing on the renamed jobs, so of course RP's will be zero.
Thoughts? Solutions?
nd39475
Enthusiast
Posts: 61 Liked: 7 times
Joined: May 05, 2016 6:28 pm
Full Name: n d
Contact:
Post
by nd39475 » Nov 21, 2019 9:35 pm
this post
I should jsut delete the OP, it's Get-VBRBackup that is failing:
PS P:\> $job = Get-VBRJob | where {$_.Name -like "Library1 Ubuntu 16-04 LTS BackupCopy"}
PS P:\> $job.Name
Library1 Ubuntu 16-04 LTS BackupCopy
PS P:\> $job.LogNameMainPart
Library1 Ubuntu 16-04 LTS BackupCopy
PS P:\> $job.TargetFile
Library1 Ubuntu 16-04 LTS BackupCopy
PS P:\> (Get-VBRBackup -Name "$job.Name")
[no result]
PS P:\> (Get-VBRBackup -Name "$job.LogNameMainPart")
[no result]
PS P:\> (Get-VBRBackup -Name "$job.TargetFile")
[no result]
nd39475
Enthusiast
Posts: 61 Liked: 7 times
Joined: May 05, 2016 6:28 pm
Full Name: n d
Contact:
Post
by nd39475 » Nov 21, 2019 9:39 pm
this post
Confirmed Get-VBRBackup produces old name
Get-VBRBackup | grep LTS
Name : Library Ubuntu 14-04 LTS Backup Copy
Path : Library Ubuntu 14-04 LTS Backup Copy
DirPath : E:\Backups\Library Ubuntu 14-04 LTS Backup Copy
PartialPath : Library Ubuntu 14-04 LTS Backup Copy
MetaFileName : Library Ubuntu 14-04 LTS Backup Copy.vbm
"Library Ubuntu 14-04 LTS Backup Copy" was renamed "Library1 Ubuntu 14-04 LTS BackupCopy"
so how do i co-relate with old names???
chris.arceneaux
VeeaMVP
Posts: 695 Liked: 374 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Georgia, USA
Contact:
Post
by chris.arceneaux » Nov 21, 2019 9:43 pm
1 person likes this post
Following the steps outlined in the blog post below will resolve the issue you're seeing:
http://www.running-system.com/how-to-re ... p-folders/
If you don't want to do that, you can always match the backups to the original Job ID.
Code: Select all
$job = Get-VBRJob -Name "renamed"
$backups = Get-VBRBackup
$backups | ?{$_.JobId -eq $job.Id}
jhoughes
Veeam Vanguard
Posts: 282 Liked: 113 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:
Post
by jhoughes » Nov 21, 2019 9:49 pm
1 person likes this post
Chris beat me to the reply, but from any backup, you can also get the source job object with the 'GetJob' method.
Code: Select all
❯ $backup = Get-VBRBackup -Name VeeamOneTest
❯ $backup.GetJob()
Job Name Type State Last Result Description
-------- ---- ----- ----------- -----------
RenameVeeamOneTest VMware Backup Working None Testing VeeamOne notifications
❯ $backup.GetJob() | Select Name, Id
Name Id
---- --
RenameVeeamOneTest 6a11abde-024f-42b1-bc01-1925136ca052
Husband, Father, Solutions Architect, Geek | @DenverVMUG & @DenverPSUG leader | International Speaker | Veeam Vanguard | vExpert (PRO) | Cisco Champion
nd39475
Enthusiast
Posts: 61 Liked: 7 times
Joined: May 05, 2016 6:28 pm
Full Name: n d
Contact:
Post
by nd39475 » Nov 21, 2019 9:55 pm
this post
Thanks guys (very much), i will wrench&hammer this ASAP in the morning.
on a side note, i was trying some of the mapping just prior, but would receive an error about the job not being excrypted and had to match; however, the jobs were indeed encrypted. love- hate relationship with veeam
chris.arceneaux
VeeaMVP
Posts: 695 Liked: 374 times
Joined: Jun 24, 2019 1:39 pm
Full Name: Chris Arceneaux
Location: Georgia, USA
Contact:
Post
by chris.arceneaux » Nov 21, 2019 10:07 pm
1 person likes this post
No worries. You must decrypt the imported backup prior to re-mapping it to the job. This doesn't mean you're removing the encryption but that you're allowing the Veeam Backup & Replication server to have access to the files in the encrypted backup.
For better instructions, the process you need to follow is almost identical to
Method B in the KB article listed below:
https://www.veeam.com/kb1729
nd39475
Enthusiast
Posts: 61 Liked: 7 times
Joined: May 05, 2016 6:28 pm
Full Name: n d
Contact:
Post
by nd39475 » Nov 21, 2019 10:58 pm
this post
yep, #2 (
https://www.veeam.com/kb1729 ) works, just a hassle, have to decrypt the import/set the CopyJob unencrypted/apply/set encrypted/finish, then jobs will trigger Active Full ;(
times 32 jobs, and double the storage of such
hopefully i can hack the code to work tomorrow. ;|
nd39475
Enthusiast
Posts: 61 Liked: 7 times
Joined: May 05, 2016 6:28 pm
Full Name: n d
Contact:
Post
by nd39475 » Nov 21, 2019 11:15 pm
this post
We need a `Get-VBRBackup -JobID` for times like this
nd39475
Enthusiast
Posts: 61 Liked: 7 times
Joined: May 05, 2016 6:28 pm
Full Name: n d
Contact:
Post
by nd39475 » Nov 21, 2019 11:26 pm
1 person likes this post
Needs a code-rework and cleanup but BOOM,producing what i need to submit to management !!
thank you thank you thank you
Code: Select all
Add-PSSnapin VeeamPSSnapIn
Function PrintRestorePoints ($jobs) {
foreach ($job in $jobs) {
$jName = $job.Name
$jSched=($job|Get-VBRJobScheduleOptions)
#$jObject= ($job|Get-VBRJobObject)
$jOptions=($job|Get-VBRJobOptions)
Write-Output "Job: $jName"
if ($job.IsScheduleEnabled) {
if ($jSched.OptionsContinuous.Enabled) { Write-Output "Job Type: Continuous" } else { Write-Output "RetainCycles: $($jOptions.Options.RootNode.RetainCycles)" }
if ($jSched.OptionsDaily.Enabled) { Write-Output "Daily Enabled" }
if ($jSched.OptionsMonthly.Enabled) { Write-Output "Monthly Enabled" }
if ($jSched.OptionsPeriodically.Enabled) { Write-Output "Periodical Enabled" }
} else { Write-Output "Job Type: Manual"}
Write-Output "RetentionPolicyType: $($jOptions.GenerationPolicy.RetentionPolicyType)"
Write-Output "SimpleRetentionRestorePoints: $($jOptions.GenerationPolicy.SimpleRetentionRestorePoints)"
#Write-Output "ActualRetentionRestorePoints: $($jOptions.GenerationPolicy.ActualRetentionRestorePoints)""
#$vbrback= (Get-VBRBackup -Name "$job.LogNameMainPart")
#$vbrback= (Get-VBRBackup -Name "$job.TargetFile")
$vbrback= (Get-VBRBackup -Name "$job.Name")
$newbackup = Get-VBRBackup | ?{$_.JobId -eq $job.Id} #due renames -- makes for much unnecessary/redundant processing
#Write-Output "Count of VM's: $($vbrback.VmCount)"
Write-Output "Count of VM's: $($newbackup.VmCount)" #due renames
#Write-Output "WeeklyBackupDayOfWeek $($jOptions.GenerationPolicy.WeeklyBackupDayOfWeek)"
#Write-Output "WeeklyBackupTime $($jOptions.GenerationPolicy.WeeklyBackupTime)"
#$restorepoints=($vbrback | Get-VBRRestorePoint)
$restorepoints=($newbackup | Get-VBRRestorePoint) #due renames
Write-Output "Count of RP`'s found: $($restorepoints.Count)"
if ($restorepoints.Count) {
$restorepoints | sort-object vmname,CreationTime | format-table -Property vmname,CreationTime -AutoSize -HideTableHeaders
} else {write-Output "`n"}
#foreach ($rp in $restorepoints) {
#$rp | Select-Object vmname,CreationTime | ft -auto
#write-Output $($rp.VmName) $($rp.CreationTime)
#}
}
} #end Function
Connect-VBRServer -server SERVERNAMEHERE -port 9392
clear
$jobs = ( Get-VBRJob | where {$_.Name -like "Library1*Copy*"} | Sort-Object -Property Name)
PrintRestorePoints ($jobs) | Tee-Object Library1_RP_Tallies.txt
$jobs = ( Get-VBRJob | where {$_.Name -like "Library2*Copy*"} | Sort-Object -Property Name)
PrintRestorePoints ($jobs) | Tee-Object Library2_RP_Tallies.txt
$jobs = ( Get-VBRJob | where {$_.Name -notlike "*Copy*"} | Sort-Object -Property Name)
PrintRestorePoints ($jobs) | Tee-Object VeeamServ_RP_Tallies.txt
Disconnect-VBRServer
Vek17
Service Provider
Posts: 49 Liked: 15 times
Joined: May 29, 2018 8:42 pm
Contact:
Post
by Vek17 » Nov 22, 2019 1:34 pm
1 person likes this post
There was an identical post a while back that raised this issue:
post342222.html#p342222
I maintain as I do in that post that this is an issue in how job renames are handled and that backups should update their "job_name" column when the linked job is renamed. AFAIK there is no critical binding on that field that prevents it and you can manually edit it to get the desired effect. Seems like an oversight of the process to me which in turn forces these bizarre work arounds.
Users browsing this forum: No registered users and 13 guests