Tape Job Priority / Backup Pause script

Everything about backing up to tape

Tape Job Priority / Backup Pause script

Veeam Logoby mc2 » Tue Aug 04, 2015 8:53 am

Case # 00981414

Opened a ticket with support regarding this, but they said I should open a feature request.

Issue we are facing is that our backup copy to tape takes a while to complete. By default Veeam will prioritise the backup o disk and kill the backup to tape job if it is running. We have a 1:1 relationship with regards to the backup to disk and backup to tape jobs, so its fairly simple in that respect.

The backups to tape are only run every fortnight which makes scheduling them around the disk jobs a bit tricky. I could just set the disk jobs to not run on the day we are running the tape jobs, but with the current scheduling options this means missing out on disk backup one day every single week, rather than just once per fortnight.

The two solutions I can think off are

1. Run a pre and post script on the tape backup job which disables the disk backup job when the tape job starts and then enables it again at the end
2. Run a pre script on the disk job which checks to see if the tape job is running and causes a pause for X time and then checks again before allowing the disk job to start

I am thinking option 1 is going to be the easiest approach as are certain we can at least schedule the tape backup job to start when the disk job isn't running.

I just really want to check I am not overthinking this, is there an easier solution?
mc2
Service Provider
 
Posts: 9
Liked: 1 time
Joined: Tue Aug 04, 2015 8:13 am
Full Name: Michael Custance

Re: Tape Job Priority / Backup Pause script

Veeam Logoby Shestakov » Tue Aug 04, 2015 10:58 am

Hello Michael,

Indeed backup jobs have a priority over backup-to-tape since making initial backup is more important than to copy existing backup file in general.
There is not much information about your particular situation in the support case, could you specify it, please? What backup jobs do you use, how often, what is the backup method?
Besides the workarounds you described, you can use backup windows to avoid overlapping and schedule the jobs to run not in a specific time, but once another job is finished.

Thanks!
Shestakov
Veeam Software
 
Posts: 4861
Liked: 395 times
Joined: Wed May 21, 2014 11:03 am
Location: Saint Petersburg
Full Name: Nikita Shestakov

Re: Tape Job Priority / Backup Pause script

Veeam Logoby mc2 » Wed Aug 05, 2015 9:53 am 1 person likes this post

Would be nice to have the option to say which job would have priority. If we were taking the backups off to tape once per week then we could use the scheduling. In our case we are running every other week. Sometimes the jobs take longer than expected also making it difficult to predict the start and end times

I think I will go with option 1 and see how it goes
mc2
Service Provider
 
Posts: 9
Liked: 1 time
Joined: Tue Aug 04, 2015 8:13 am
Full Name: Michael Custance

Re: Tape Job Priority / Backup Pause script

Veeam Logoby chas0rde » Wed Aug 05, 2015 11:07 am

Same problem here. Currently fixed it with your solution #2. Works but is not very elegant and not very change resilient (e.g. if jobs are renamed my script requires to be updated...that could be fixed but I think it should be configurable !)
chas0rde
Enthusiast
 
Posts: 28
Liked: 3 times
Joined: Wed Jan 14, 2015 7:01 am

Re: Tape Job Priority / Backup Pause script

Veeam Logoby mc2 » Wed Aug 05, 2015 12:02 pm

Hi Chas0rde

Would you be up for sharing your script?
mc2
Service Provider
 
Posts: 9
Liked: 1 time
Joined: Tue Aug 04, 2015 8:13 am
Full Name: Michael Custance

Re: Tape Job Priority / Backup Pause script

Veeam Logoby Dima P. » Wed Aug 05, 2015 1:18 pm

Hi guys,
Would be nice to have the option to say which job would have priority.

Counted as a feature request. Meanwhile, can I ask why the option “If some linked backup jobs are still running, wait for up to … minutes” for backup to tape job does not solve the running job issue? Thanks
Dima P.
Veeam Software
 
Posts: 6249
Liked: 440 times
Joined: Mon Feb 04, 2013 2:07 pm
Location: SPb
Full Name: Dmitry Popov

Re: Tape Job Priority / Backup Pause script

Veeam Logoby chas0rde » Mon Aug 17, 2015 8:24 am

mc2 wrote:Hi Chas0rde

Would you be up for sharing your script?

Yes but I would like to do some improvements first. Once that is done I am happy to share :)
chas0rde
Enthusiast
 
Posts: 28
Liked: 3 times
Joined: Wed Jan 14, 2015 7:01 am

Re: Tape Job Priority / Backup Pause script

Veeam Logoby mc2 » Mon Aug 17, 2015 10:57 am

thank you, ill wait for your update :)
mc2
Service Provider
 
Posts: 9
Liked: 1 time
Joined: Tue Aug 04, 2015 8:13 am
Full Name: Michael Custance

Re: Tape Job Priority / Backup Pause script

Veeam Logoby chas0rde » Thu Aug 27, 2015 7:35 am

Still working on the improvements (or waiting to find time to do them)
What I can say is that this does not work very well, as after some time VBR reports in the backup-to-disk job that the pre-script timed out. So it seems that "unlimited wait" is not possible or the script needs some tweaking
Currently I have a support case open with Veeam...we'll see if they find a solution

I'll keep you guys posted
chas0rde
Enthusiast
 
Posts: 28
Liked: 3 times
Joined: Wed Jan 14, 2015 7:01 am

Re: Tape Job Priority / Backup Pause script

Veeam Logoby mc2 » Thu Aug 27, 2015 8:07 am

thank you for the update, I may go back to the plan of disabling the "disk" job a the start of the tape and then enable again at the end. Only draw back I guess is if the job was scheduled to run while it was disabled we would miss one of the backups
mc2
Service Provider
 
Posts: 9
Liked: 1 time
Joined: Tue Aug 04, 2015 8:13 am
Full Name: Michael Custance

Re: Tape Job Priority / Backup Pause script

Veeam Logoby teamlotus81 » Fri May 13, 2016 1:21 pm

Hi Chas0rde

Would it be possible for you to share the pause script?
teamlotus81
Lurker
 
Posts: 2
Liked: never
Joined: Mon Feb 29, 2016 4:13 pm
Full Name: Thomas Beach

Re: Tape Job Priority / Backup Pause script

Veeam Logoby v.Eremin » Tue May 17, 2016 3:41 pm

You can take the following script as an rough example:

Code: Select all
asnp VeeamPSSnapin
do
{
$TapeJob = Get-VBRTapeJob -name "Name of your backup to tape job"
Start-Sleep -Seconds 300
} while ($TapeJob.LastState -eq "Working")


Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Tape Job Priority / Backup Pause script

Veeam Logoby chas0rde » Fri Jul 22, 2016 9:47 am

Hello
I still did not find time to solve this issue to full satisfaction.
Pre-Job for the To-Disk-Job won't work:

1) Pre-Job will run into a timeout after some time and then continue the job thus killing the backup-to-tape. So this just gives you a "grace-period" of a sort
2) Pre-job have no parameter to set what should happen if they fail/timeout. Pre-Freeze has the option e.g. to fail the job if script fails. This would be nice for pre-/post-job as well, as sometimes with pre-/post-job scripts not going through correctly the backup might be inconsistent anyways (e.g. with multi-tier server infrastructures where several services need to be stopped before backup)

Basically my script does the same as the one mentioned by v.eremin

Here is the rough version (no guarantee for function/quality et cetera...still work in progress)
Code: Select all
<#
  .NAME
    Veeam_Wait_for_TapeJob_pre.ps1
  .SYNOPSIS
    This script causes a Veeam Backup and Recovery Job to wait for its tape job to finish before running.
    This helps prevent the tape job being aborted by the Backup-to-disk jo by setting it as a pre-run script.
    If none or only some of the supplied scheduling suffixes are found a warning is generated.
  .PARAMETER Job
    The Tape Job to check
  .PARAMETER scheduling_suffix
    Comma-separated list of possible suffixes for Tape jobs. E.g. M for monthly, Q for quarterly.
    This parameter is used to cycle through all possible Tape jobs, that might be interrupted by a backup-to-disk
    job.
  .PARAMETER [logfile]
    Optional parameter to indicate the logfile to use. If not given logging is done to C:\temp\Veeam_pre-script\<jobname>
    Logfiles older than 15 days will be removed.
  .NOTES
    Author: Ingo Pohlschneider <info@chas0r.de>
    Date:   August 03, 2015
#>

# define commandline parameters
param([Parameter(Mandatory=$true)][string]$Job,
      [Parameter(Mandatory=$true)][string]$scheduling_suffix,
      [string]$logfile)

if (-Not ($logfile)) {
    $logtime = Get-Date -Format "yyyyMMdd_hhmmss"
    $logpath = "C:\Temp\Veeam_pre-script\" + $job
    $logfile = $logpath + "\PS_LOG_Veeam_Wait_for_TapeJob_" + $job + "_" + $logtime + ".log"
} else {
    $logpath = Split-Path $logfile
}

# create logpath if not exists
New-Item -ItemType Directory -Force -Path $logpath

# cleanup old logfiles
$limit = (Get-Date).AddDays(-15)
# Delete files older than the $limit.
Get-ChildItem -Path $logpath -Recurse -Force | Where-Object { !$_.PSIsContainer -and $_.CreationTime -lt $limit } | Remove-Item -Force

Write-Output "Transcript log: " $logfile
Start-Transcript -path $logfile

#TEST GET JOBNAME AUTOMATICALLY
$parentpid = (Get-WmiObject Win32_Process -Filter "processid='$pid'").parentprocessid.ToString()
$parentcmd = (Get-WmiObject Win32_Process -Filter "processid='$parentpid'").CommandLine
$autojob = Get-VBRJob | ?{$parentcmd -like "*"+$_.Id.ToString()+"*"}
$session = Get-VBRBackupSession | ?{($_.OrigJobName -eq $autojob.Name) -and ($parentcmd -like "*"+$_.Id.ToString()+"*")}

Write-Output "AUTOJOB determined is $($autojob)"

Write-Output "Supplied Jobname is $($Job)"
Write-Output "Supplied scheduling suffixes are $($scheduling_suffix)"

# Load the Veeam Powershell Snapin
if (-not (Get-PSSnapin VeeamPSSnapin -ErrorAction SilentlyContinue)) {
   Write-Output "Activating VeeamPSSnapin"
   Add-PSSnapin VeeamPSSnapin
}

# Create array from suffix-list
[string[]]$suffixes = $scheduling_suffix.split(",")
Write-Output "Found the following suffixes:  $($suffixes)"
Write-Output "Checking $($suffixes.Length) Tape Jobs"

# Cycle through tape jobs and see if one of them is still running
$count = 0
$ec = 0
foreach ($suffix in $suffixes) {
    $curJob = $Job + "_" + $suffix
    Write-Output "Checking $($curJob)"
    if (-not ($TapeJob = Get-VBRTapeJob -name "$($curJob)" -ErrorAction SilentlyContinue)) {
        Write-Output "Tape Job $($curJob) was not found"
        $count++
    } else {
        $State = $TapeJob.LastState
        while ($State -ne "Stopped") {
            Write-Output "Tape Job $($curJob) still running. Waiting 60 seconds"
            Start-sleep -s 60
            $State = $TapeJob.LastState
        }
        Write-Output "Tape Job $($curJob) not running"
    }

    # Check if no job was found
    if ($count -eq $suffixes.Length) {
        Write-Output "No matching Tape Jobs found!"
        $ec = 2
    } elseif ($count -gt 0) {
        Write-Output "Some Tape Jobs matching the scheduling suffixes supplied were not found!"
        $ec = 3
    }
}

Write-Output "Exiting with exit code $($ec)"
Stop-Transcript
exit $ec
chas0rde
Enthusiast
 
Posts: 28
Liked: 3 times
Joined: Wed Jan 14, 2015 7:01 am


Return to Tape



Who is online

Users browsing this forum: Google [Bot] and 5 guests