Defined Type: bacula::job

Defined in:
manifests/job.pp

Summary

Define a Bacula Job

Overview

This class installs a bacula job on the director. This can be used for specific applications as well as general host backups

Examples:

bacula::job { "${fqdn}-common":
  fileset => "Root",
}
bacula::job { "${fqdn}-mywebapp":
  files    => ["/var/www/mywebapp","/etc/mywebapp"],
  excludes => ["/var/www/mywebapp/downloads"],
}

Parameters:

  • files (Array[Stdlib::Absolutepath]) (defaults to: [])

    An array of files that you wish to get backed up on this job for this host. ie: [“/etc”,“/usr/local”]

  • excludes (Array[Stdlib::Absolutepath]) (defaults to: [])

    An array of files to skip for the given job. ie: [“/usr/local/src”]

  • fileset (Optional[String[1]]) (defaults to: undef)

    If set to true, a fileset will be genereated based on the files and excludes paramaters specified above. If set to false, the job will attempt to use the fileset named “Common”. If set to anything else, provided it’s a String, that named fileset will be used. NOTE: the fileset Common or the defined fileset must be declared elsewhere for this to work. See Class::Bacula for details

  • jobtype (Bacula::JobType) (defaults to: 'Backup')

    The type of job

  • template (String[1]) (defaults to: 'bacula/job.conf.epp')

    Template to use for generating the job configuration fragment

  • pool (Optional[String[1]]) (defaults to: undef)

    Name of the pool to use by default for this job

  • pool_full (Optional[String[1]]) (defaults to: undef)

    Name of the pool to use for Full jobs

  • pool_inc (Optional[String[1]]) (defaults to: undef)

    Name of the pool to use for Incremental jobs

  • pool_diff (Optional[String[1]]) (defaults to: undef)

    Name of the pool to use for Differential jobs

  • storage (Optional[String[1]]) (defaults to: undef)

    Name of the storage service to use

  • jobdef (Variant[Boolean, String[1]]) (defaults to: 'Default')

    If a JobDefs-Resource-Name is specified, all the values contained in the named JobDefs resource will be used as the defaults for the current Job

  • runscript (Array[Bacula::Runscript]) (defaults to: [])

    Array of hash(es) containing RunScript directives

  • level (Optional[String[1]]) (defaults to: undef)

    The Level directive specifies the default Job level to be run

  • accurate (Bacula::Yesno) (defaults to: false)

    In accurate mode, the File daemon knowns exactly which files were present after the last backup. So it is able to handle deleted or renamed files

  • reschedule_on_error (Bacula::Yesno) (defaults to: false)

    boolean for enableing disabling job option “Reschedule On Error”

  • reschedule_interval (Bacula::Time) (defaults to: '1 hour')

    time-spec for job option “Reschedule Interval”

  • reschedule_times (Integer) (defaults to: 10)

    count for job option “Reschedule Times”

  • messages (Optional[String[1]]) (defaults to: undef)

    containing the name of the message resource to use for this job set to false to disable this option

  • restoredir (Stdlib::Absolutepath) (defaults to: '/tmp/bacula-restores')

    containing the prefix for restore jobs

  • sched (Optional[String[1]]) (defaults to: undef)

    containing the name of the scheduler set to false to disable this option

  • priority (Optional[Integer]) (defaults to: undef)

    containing the priority number for the job set to false to disable this option

  • job_tag (Optional[String[1]]) (defaults to: undef)

    that might be used for grouping of jobs. Pass this to bacula::director to only collect jobs that match this tag

  • selection_type (Optional[String[1]]) (defaults to: undef)

    Determines how the migration job will go about selecting what JobIds to migrate

  • selection_pattern (Optional[String[1]]) (defaults to: undef)

    Pattern to match against to filter items with selection_type

  • max_concurrent_jobs (Integer[1]) (defaults to: 1)

    Maximum number of Jobs from the current Job resource that can run concurrently

  • write_bootstrap (Optional[String[1]]) (defaults to: undef)

    The writebootstrap directive specifies a file name where Bacula will write a bootstrap file for each Backup job run

  • max_full_interval (Optional[Bacula::Time]) (defaults to: undef)

    The time specifies the maximum allowed age (counting from start time) of the most recent successful Full backup that is required in order to run Incremental or Differential backup jobs. f the most recent Full backup is older than this interval, Incremental and Differential backups will be upgraded to Full backups automatically.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
# File 'manifests/job.pp', line 44

define bacula::job (
  Array[Stdlib::Absolutepath] $files               = [],
  Array[Stdlib::Absolutepath] $excludes            = [],
  Optional[String[1]]         $fileset             = undef,
  Bacula::JobType             $jobtype             = 'Backup',
  String[1]                   $template            = 'bacula/job.conf.epp',
  Optional[String[1]]         $pool                = undef,
  Optional[String[1]]         $pool_full           = undef,
  Optional[String[1]]         $pool_inc            = undef,
  Optional[String[1]]         $pool_diff           = undef,
  Optional[String[1]]         $storage             = undef,
  Variant[Boolean, String[1]] $jobdef              = 'Default',
  Array[Bacula::Runscript]    $runscript           = [],
  Optional[String[1]]         $level               = undef,
  Bacula::Yesno               $accurate            = false,
  Bacula::Yesno               $reschedule_on_error = false,
  Bacula::Time                $reschedule_interval = '1 hour',
  Integer                     $reschedule_times    = 10,
  Optional[String[1]]         $messages            = undef,
  Stdlib::Absolutepath        $restoredir          = '/tmp/bacula-restores',
  Optional[String[1]]         $sched               = undef,
  Optional[Integer]           $priority            = undef,
  Optional[String[1]]         $job_tag             = undef,
  Optional[String[1]]         $selection_type      = undef,
  Optional[String[1]]         $selection_pattern   = undef,
  Integer[1]                  $max_concurrent_jobs = 1,
  Optional[String[1]]         $write_bootstrap     = undef,
  Optional[Bacula::Time]      $max_full_interval   = undef,
) {
  include bacula
  include bacula::client
  $conf_dir = $bacula::conf_dir

  if empty($files) and ! $fileset {
    fail('Must pass either a list of files or a fileset')
  }

  $tag_defaults = ["bacula-${bacula::director_name}"]

  if $job_tag {
    $resource_tags = $tag_defaults + [$job_tag]
  } else {
    if $bacula::job_tag {
      $resource_tags = $tag_defaults + [$bacula::job_tag]
    } else {
      $resource_tags = $tag_defaults
    }
  }

  if $fileset {
    $fileset_real = $fileset
  } else {
    if $files or $excludes {
      $fileset_real = $name
      @@bacula::director::fileset { $name:
        files    => $files,
        excludes => $excludes,
        tag      => $resource_tags,
      }
    } else {
      $fileset_real = 'Common'
    }
  }

  $epp_job_variables = {
    name                => $name,
    jobtype             => $jobtype,
    fileset_real        => $fileset_real,
    pool                => $pool.lest || { $bacula::client::default_pool },
    storage             => $storage,
    restoredir          => $restoredir,
    messages            => $messages,
    pool_full           => $pool_full.lest || { $bacula::client::default_pool_full },
    pool_inc            => $pool_inc.lest || { $bacula::client::default_pool_inc },
    pool_diff           => $pool_diff.lest || { $bacula::client::default_pool_diff },
    selection_type      => $selection_type,
    selection_pattern   => $selection_pattern,
    jobdef              => $jobdef,
    runscript           => $runscript,
    accurate            => $accurate,
    level               => $level,
    sched               => $sched,
    priority            => $priority,
    max_concurrent_jobs => $max_concurrent_jobs,
    reschedule_on_error => $reschedule_on_error,
    reschedule_interval => $reschedule_interval,
    reschedule_times    => $reschedule_times,
    write_bootstrap     => $write_bootstrap,
    max_full_interval   => $max_full_interval,
  }

  @@bacula::director::job { $name:
    content => epp($template, $epp_job_variables),
    tag     => $resource_tags,
  }
}