Pruning Directives
There are three pruning durations. All apply to catalog database Jobs and Files records and not to the actual data in a Volume. The pruning (or retention) durations are for: Volumes (Jobs and Files records in the Volume), Jobs (Job records), and Files (File records). The durations inter-depend a bit because if Bacula prunes a Volume, it automatically removes all the Job records, and, consequently, all the File records. Also when a Job record is pruned, all the File records for that Job are also pruned (deleted) from the catalog.
Having the File records in the database means that you can examine all the files backed up for a particular Job. They take the most space in the catalog (probably 90-95% of the total). When the File records are pruned, the Job records can remain, and you can still examine what Jobs ran, but not the details of the Files backed up. In addition, without the File records, you cannot use the Console restore command to restore specific files.
When a Job record is pruned, the Volume (Media record) for that Job can still remain in the database, and if you do a list volumes, you will see the volume information, but the Job records (and its File records) will no longer be available.
In each case, pruning removes information about where older files are, but it also prevents the catalog from growing to be too large. You choose the retention periods in function of how many files you are backing up and the time periods you want to keep those records online, and the size of the database. You can always re-insert the records (with 98% of the original data) by using bscan to scan in a whole Volume or any part of the volume that you want.
By setting AutoPrune to yes you will permit Bacula to automatically prune Volumes in the Pool when a Job needs a Volume. Volume pruning means removing Jobs and Files records from the catalog. It does not shrink the size of the Volume or affect the Volume data until the Volume gets overwritten. When a Job requests a volume and there are no Volumes with Volume Status , or available, Bacula will begin volume pruning. This means that all Jobs that are older than the VolumeRetention period will be pruned from every Volume that has Volume Status or and has Recycle set to yes. Pruning consists of deleting the corresponding Job, File, and JobMedia records from the catalog database. No change to the physical data on the Volume occurs during the pruning process. When all files are pruned from a Volume (i.e. no records in the catalog), the Volume will be marked as implying that no Jobs remain on the volume. The Pool records that control the pruning are described below.
AutoPrune = <yes|no> If AutoPrune is set to yes**(default), **Bacula will automatically apply the Volume retention period when running a Job and it needs a new Volume but no appendable volumes are available. At that point, Bacula will prune all Volumes that can be pruned (i.e. AutoPrune set) in an attempt to find a usable volume. If during the autoprune, all files are pruned from the Volume, it will be marked with VolStatus . The default is yes. Note, that although the File and Job records may be pruned from the catalog, a Volume will be marked Purged (and hence ready for recycling) if the Volume status is Append, Full, Used, or Error. If the Volume has another status, such as Archive, Read-Only, Disabled, Busy, or Cleaning, the Volume status will not be changed to Purged.
Volume Retention = <time-period-specification> The Volume Retention record defines the length of time that Bacula will guarantee that the Volume is not reused (i.e. recycled). As long as a Volume has the status Append, it will not be recycled even though the retention period may have expired, until the status is changed to some other status such as Full, Used, Purged, …
The retention period when applied starts at the time of the last write to the Volume. For a Volume to recycled, the volume must not have a status of Append and the retention period must have expired. Even in that case, the Volume will not be recycled if any other appendable Volume is available for the Job to complete. As noted above, the Volume status will be marked Purged by Bacula prior to it being recycled.
Note, when all the Job records that are on the Volume have been removed, the Volume will be marked (i.e. it has no more valid Jobs stored on it), and the Volume may be recycled even if the Volume Retention period has not expired.
When this time period expires, and if AutoPrune is set to yes, and a new Volume is needed, but no appendable Volume is available, Bacula will prune (remove) Job records that are older than the specified Volume Retention period even if the Job or File retention has not been reached. Normally this should not happen since the Volume Retention period should always be set greater than the Job Retention period, which should be greater than the File Retention period.
The Volume Retention period takes precedence over any Job Retention period you have specified in the Client resource. It should also be noted, that the Volume Retention period is obtained by reading the Catalog Database Media record rather than the Pool resource record. This means that if you change the VolumeRetention in the Pool resource record (in bacula-dir.conf), you must ensure that the corresponding change is made in the catalog by using the update pool command. Doing so will insure that any new Volumes will be created with the changed Volume Retention period. Any existing Volumes will have their own copy of the Volume Retention period that can only be changed on a Volume by Volume basis using the update volume command.
When all Job catalog entries are removed from the volume, its VolStatus is set to . The files remain physically on the Volume until the volume is overwritten.
Retention periods are specified in seconds, minutes, hours, days, weeks, months, quarters, or years on the record. See the Configuration chapter of this manual for additional details of time specification.
The default Volume Retention period is 1 year.
Recycle = <yes|no> This statement tells Bacula whether or not the particular Volume can be recycled (i.e. rewritten). If Recycle is set to no, then even if Bacula prunes all the Jobs on the volume and it is marked , it will not consider the volume for recycling. If Recycle is set to yes (the default) and all Jobs have been pruned, the volume status will be set to and the volume may then be reused when another volume is needed. If the volume is reused, it is relabeled with the same Volume Name, however all previous data will be lost.
It is also possible to “force” pruning of all Volumes in the Pool associated with a Job by adding Prune Files=yes to the Job resource.
See also
Go to Disabling Automatic Pruning.
Go back to the Pruning chapter.
Go back to the Storage Space Management chapter.
Go back to the main Bacula Enterprise chapter.