Disabling Automatic Pruning

In order to disable automatic pruning of Jobs and files, you should:

  • In Job{} resources, avoid the usage of Prune Jobs = yes and Prune Files = yes.

  • In all Client{} resources, configure AutoPrune = no.

In order to disable automatic pruning of volumes, you should:

  • In the Job{} resources, avoid the usage of Prune Volumes = yes.

  • In all Pool{} resources, configure AutoPrune = no.

Once your Jobs, Clients and Pools have all been edited, you must tell the Director to reload its configuration.

Run the following command to validate your modifications

/opt/bacula/bin/bacula-dir -t -u bacula -g bacula

Then reload the configuration from bconsole with:

reload

After disabling automatic pruning for Jobs, files and Volumes in all the defined resources, Bacula will no longer perform any automatic pruning. As you might suspect, with no automatic pruning, the Catalog database would grow forever, so we need to perform pruning manually or in a more automated way by using an Admin type Job.

Automated Scheduled Pruning When AutoPrune=no

If you don’t do anything more, your Catalog will grow infinitely. To keep it at its best, you should define an “Admin” job, like the following:

Job {
   Name = "admin-manual-pruning"
   Type = Admin
   JobDefs = "DefaultJob"
   RunScript {
      Runs When = Before
      # below command relies on proper PATH!
      Command = "/bin/sh -c \"echo prune expired volume yes\" | bconsole"
      Runs On Client = no
   }
   Schedule = s-Prune
}

As a Bacula volume can contain one or more jobs (or parts of jobs) and a job contains one or more files, the pruning process will have side effects:

  • when pruning a Volume, all the jobs related to the Volume are pruned

  • when pruning a Job, all the files related to this jobs are pruned

That is the reason why you should have the following:

\[R_f \leqslant R_j \leqslant R_v\]

Where:

  • \(R_f\) is the File retention period

  • \(R_j\) is the Job retention period

  • \(R_v\) is the Volume retention period

In some cases, you might want to disable any form of pruning/purging for a specific Job without changing the configuration of the Client, Job or Pool resources.

It is possible with the update jobid=x prune=no bconsole command to update the Prune catalog attribute for the given Job.

If the Prune Job’s catalog attribute is no (2 in the catalog) or files (1 in the catalog), Bacula will not be able to purge the job record (or the file records) and recycle the associated volumes.

To enable back the regular Job pruning algorithm, use update jobid=x prune=yes bconsole command.

To disable the pruning/purging algorithm at the Job resource level, use the PruneJobs=never or PruneFiles=never directives.

Job {
   Name = "BackupCatalog"
   Type = Backup
   JobDefs = "DefaultJob"
   PruneFiles = never
   PruneJobs = never   # implied by PruneFiles = never
}

Should you wish to have volumes pruned for specific pools, you can do so by using separated prune commands for the different pools, such as the following:

echo "prune expired volume pool=Pool_1 yes" | /opt/bacula/bin/bconsole > /tmp/prunePool_1.log
echo "prune expired volume pool=Pool_2 yes" | /opt/bacula/bin/bconsole > /tmp/prunePool_2.log
echo "prune expired volume pool=Pool_3 yes" | /opt/bacula/bin/bconsole > /tmp/prunePool_3.log

See also

Go to Pruning Directives.

Go back to the Pruning chapter.

Go back to the Storage Space Management chapter.

Go back to the main Bacula Enterprise chapter.