Re: [bareos-users] Do Not Try to Run Duplicated Jobs

2021-11-16 Thread 'Birgit Ducarroz' via bareos-users
Hi Jon,

First of all, sorry for my late answer.
This is working like a charm, thank you a lot!!
Regards,
Birgit

Jon Schewe schrieb am Dienstag, 9. November 2021 um 17:21:31 UTC+1:

> The handling of canceled jobs in bareos has caused me some issues, 
> particularly because a canceled job is not considered success, so if you 
> have rerun failed levels enabled you can end up running the same level over 
> and over. My solution here deals with that by deleting the canceled jobs, 
> which is what you want.
>
>
> /etc/bareos/bareos-dir.d/jobdefs/LTO-Backup.conf
> JobDefs { 
>   Name = "LTO-Backup"
>   Type = Backup
>   Level = Incremental
>   Schedule = "WeeklyCycle"
>   Messages = Standard
>   Pool = LTO-5
>   Priority = 30
>   Rerun Failed Levels = yes
>   Accurate = yes
>   Spool Data = yes
>
>   # retry failed backups
>   Reschedule On Error = yes
>   Reschedule Interval = 1 minute 
>   Reschedule Times = 10
>   
>   #Write Bootstrap = "|/usr/bin/bsmtp -h localhost -f \"\(Bareos\) \" -s 
> \"Bootstrap for Job %j\" root@localhost" # (#01)
>   Write Bootstrap = /var/lib/bareos/bootstrap/%c.bsr
>
>   AllowDuplicateJobs = no
>   CancelLowerLevelDuplicates = yes
>   CancelQueuedDuplicates = yes
>
>   # handle long running jobs and canceling duplicates
>   RunScript {
> RunsWhen = After
> RunsOnFailure = Yes
> FailJobOnError = No
> RunsOnClient = No
> Command = "/etc/bareos/delete-canceled-job.sh %e %i"
>   }
>
> }
>
>
>
> /etc/bareos/delete-canceled-job.sh
> #!/bin/sh 
>
> debug() { ! "${log_debug-false}" || log "DEBUG: $*" >&2; }
> log() { printf '%s\n' "$*"; }
> warn() { log "WARNING: $*" >&2; }
> error() { log "ERROR: $*" >&2; }
> fatal() { error "$*"; exit 1; }
> try() { "$@" || fatal "'$@' failed"; }
>
> mydir=$(cd "$(dirname "$0")" && pwd -L) || fatal "Unable to determine 
> script directory"
>
> # call as delete-canceled-job.sh %e %i
> status=$1
> jobid=$2
>
> if [ "Canceled" = "${status}" ]; then
> log "Deleting canceled job ${jobid}"
> #echo "Run 'delete jobid=${jobid}' inside bareos console" | mail -s 
> "delete canceled" jon.s...@raytheon.com
> #echo "delete jobid=${jobid} | bconsole"
>
> # schedule with at so that the job can complete and then later be 
> deleted
> echo "/etc/bareos/delete-canceled-job_doit.sh ${jobid}" | at now + 2 
> minutes 
> fi
>
>
>
> /etc/bareos/delete-canceled-job_doit.sh
> #!/bin/sh 
>
> debug() { ! "${log_debug-false}" || log "DEBUG: $*" >&2; }
> log() { printf '%s\n' "$*"; }
> warn() { log "WARNING: $*" >&2; }
> error() { log "ERROR: $*" >&2; }
> fatal() { error "$*"; exit 1; }
> try() { "$@" || fatal "'$@' failed"; }
>
> mydir=$(cd "$(dirname "$0")" && pwd -L) || fatal "Unable to determine 
> script directory"
>
> # called from at, scheduled by delete-canaceled-job.sh
> jobid=$1
>
> debug "Deleting canceled job ${jobid}"
> #echo "Run 'delete jobid=${jobid}' inside bareos console" | mail -s 
> "delete canceled" jon.s...@raytheon.com
>
> output=$(echo "delete jobid=${jobid}" | bconsole 2>&1)
> if [ $? -ne 0 ]; then
> error ${output}
> fatal "Error deleting job ${jobid}"
> fi
>
> # output anything that we don't expect
> echo "${output}" \
> | grep -v "Automatically selected Catalog" \
> | grep -v "Using Catalog" \
> | grep -v "You have messages" \
> | grep -v "deleted from the catalog" \
> | grep -v "delete jobid=${jobid}" \
> | grep -v "Enter a period" \
> | grep -v "You are connected using" \
> | grep -v "Get official binaries and vendor support" \
> | grep -v "bareos.org binaries are UNSUPPORTED by bareos.com" \
> | grep -v "bareos.org build binary" \
>         | grep -v "1000 OK" \
> | grep -v "Encryption:" \
> | grep -v "Connecting to Director" \
> | grep -v -e '^[[:space:]]*$'
>
> # debugging
> #echo "delete jobid=${jobid}" \
> #| bconsole 2>&1 
> #log "

Re: [bareos-users] Do Not Try to Run Duplicated Jobs

2021-11-09 Thread 'Jon SCHEWE' via bareos-users
The handling of canceled jobs in bareos has caused me some issues, particularly 
because a canceled job is not considered success, so if you have rerun failed 
levels enabled you can end up running the same level over and over. My solution 
here deals with that by deleting the canceled jobs, which is what you want.


/etc/bareos/bareos-dir.d/jobdefs/LTO-Backup.conf
JobDefs {
  Name = "LTO-Backup"
  Type = Backup
  Level = Incremental
  Schedule = "WeeklyCycle"
  Messages = Standard
  Pool = LTO-5
  Priority = 30
  Rerun Failed Levels = yes
  Accurate = yes
  Spool Data = yes

  # retry failed backups
  Reschedule On Error = yes
  Reschedule Interval = 1 minute
  Reschedule Times = 10

  #Write Bootstrap = "|/usr/bin/bsmtp -h localhost -f \"\(Bareos\) \" -s 
\"Bootstrap for Job %j\" root@localhost" # (#01)
  Write Bootstrap = /var/lib/bareos/bootstrap/%c.bsr

  AllowDuplicateJobs = no
  CancelLowerLevelDuplicates = yes
  CancelQueuedDuplicates = yes

  # handle long running jobs and canceling duplicates
  RunScript {
RunsWhen = After
RunsOnFailure = Yes
FailJobOnError = No
RunsOnClient = No
Command = "/etc/bareos/delete-canceled-job.sh %e %i"
  }

}



/etc/bareos/delete-canceled-job.sh
#!/bin/sh

debug() { ! "${log_debug-false}" || log "DEBUG: $*" >&2; }
log() { printf '%s\n' "$*"; }
warn() { log "WARNING: $*" >&2; }
error() { log "ERROR: $*" >&2; }
fatal() { error "$*"; exit 1; }
try() { "$@" || fatal "'$@' failed"; }

mydir=$(cd "$(dirname "$0")" && pwd -L) || fatal "Unable to determine script 
directory"

# call as delete-canceled-job.sh %e %i
status=$1
jobid=$2

if [ "Canceled" = "${status}" ]; then
log "Deleting canceled job ${jobid}"
#echo "Run 'delete jobid=${jobid}' inside bareos console" | mail -s "delete 
canceled" jon.sch...@raytheon.com
#echo "delete jobid=${jobid} | bconsole"

# schedule with at so that the job can complete and then later be deleted
echo "/etc/bareos/delete-canceled-job_doit.sh ${jobid}" | at now + 2 minutes
fi



/etc/bareos/delete-canceled-job_doit.sh
#!/bin/sh

debug() { ! "${log_debug-false}" || log "DEBUG: $*" >&2; }
log() { printf '%s\n' "$*"; }
warn() { log "WARNING: $*" >&2; }
error() { log "ERROR: $*" >&2; }
fatal() { error "$*"; exit 1; }
try() { "$@" || fatal "'$@' failed"; }

mydir=$(cd "$(dirname "$0")" && pwd -L) || fatal "Unable to determine script 
directory"

# called from at, scheduled by delete-canaceled-job.sh
jobid=$1

debug "Deleting canceled job ${jobid}"
#echo "Run 'delete jobid=${jobid}' inside bareos console" | mail -s "delete 
canceled" jon.sch...@raytheon.com

output=$(echo "delete jobid=${jobid}" | bconsole 2>&1)
if [ $? -ne 0 ]; then
error ${output}
fatal "Error deleting job ${jobid}"
fi

# output anything that we don't expect
echo "${output}" \
| grep -v "Automatically selected Catalog" \
| grep -v "Using Catalog" \
| grep -v "You have messages" \
| grep -v "deleted from the catalog" \
| grep -v "delete jobid=${jobid}" \
| grep -v "Enter a period" \
| grep -v "You are connected using" \
| grep -v "Get official binaries and vendor support" \
| grep -v "bareos.org binaries are UNSUPPORTED by bareos.com" \
| grep -v "bareos.org build binary" \
| grep -v "1000 OK" \
| grep -v "Encryption:" \
| grep -v "Connecting to Director" \
| grep -v -e '^[[:space:]]*$'

# debugging
#echo "delete jobid=${jobid}" \
#| bconsole 2>&1
#log "status $?"

exit 0


Jon Schewe

Principal Software Systems Technologist

C: +1 612.263.2718

O: +1 952.545.5720

jon.sch...@raytheon.com

Raytheon Technologies

Raytheon Intelligence & Space

5775 Wayzata Blvd. Suite 630

St. Louis Park, MN 55416


RTX.com<https://www.rtx.com/> | 
LinkedIn<https://www.linkedin.com/company/raytheontechnologies> | 
Twitter<https://twitter.com/raytheontech> | 
Instagram<https://www.instagram.com/raytheontechnologies>


From: 'Birgit Ducarroz' via bareos-users 
Sent: Tuesday, November 9, 2021 03:06
To: bareos-users 
Subject: [External] [bareos-users] Do Not Try to Run Duplicated Jobs


Hi list,

Is there a possibility to not run and then cancel duplicated jobs?
In my ac

[bareos-users] Do Not Try to Run Duplicated Jobs

2021-11-09 Thread 'Birgit Ducarroz' via bareos-users

Hi list,

Is there a possibility to not run and then cancel duplicated jobs?
In my actual config...

Allow Duplicate Jobs = no
Cancel Lower Level Duplicates = yes
Cancel Queued Duplicates = yes

... duplicate jobs cancel which creates me a lot of canceled jobs in the 
dashboard while running a set of full backups which are running more than 
one day. But I even don't want to list all these canceled jobs.

Thank you for any hint!
Kind regards,
Birgit

-- 
You received this message because you are subscribed to the Google Groups 
"bareos-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to bareos-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/bareos-users/46d2bc51-b789-47bc-a328-4b2386e98fd3n%40googlegroups.com.