On 01/18/17 09:27, Daniel Heitepriem wrote: > My second question is whether it is possible for bacula to delete a > volume (also the created volume file on a hard disk) after a specific > amount of time (e.g. 4 weeks)? So I create a backup at the beginning of > the month and at the end of the month bacula is automatically deleting > all records from the database (File/Job/Volume retention would apply > here?) and also deletes the created volume file from the disk.
Bacula itself will not do this. However, you can do it using a properly constructed admin job. Consider the following Pool definition: Pool { Name = Incr-Disk Storage = babylon4-file Pool Type = Backup Recycle = no Recycle Oldest Volume = no Recycle Current Volume = no AutoPrune = yes Volume Retention = 1 month File Retention = 1 month Maximum Volume Jobs = 0 Volume Use Duration = 23h Label Format = "INCR-$Year${Month:p/2/0/r}${Day:p/2/0/r}-${Hour:p/2/0/r}:${Minute:p/2/0/r}" RecyclePool = Scratch } This pool auto-creates new disk volumes as needed, allows each volume to be used for a single day's incremental backups, auto-prunes all of the jobs on the volume when it is one month old, and then recycles it into the Scratch pool. Once in the Scratch pool, it is picked up by this admin job: Job { Name = "Clean Expired Volumes" Type = Admin Enabled = Yes Pool = Scratch FileSet = Dummy Storage = babylon4-file Client = babylon4 Level = Full RunBeforeJob = "/etc/bacula/clean_volumes -v" Rerun Failed Levels = yes Messages = Daemon Priority = 20 Allow Duplicate Jobs = no Cancel Queued Duplicates = yes Schedule = "Volume Cleanup" } The admin job calls this Perl script, which calls bconsole to delete the volumes from Bacula's catalog, and then physically deletes the disk files: #!/usr/bin/perl use strict; use Getopt::Long; use IPC::Open2; use IO::Handle; my $bconsole = '/usr/sbin/bconsole'; my (%opts, @purged, $pid); GetOptions(\%opts, 'verbose|v', 'test'); my ($IN, $OUT) = (IO::Handle->new(), IO::Handle->new()); $pid = open2($OUT, $IN, $bconsole) || die "Unable to open bconsole"; if (scalar (@purged = check_volumes())) { printf("Bacula reports the following purged volumes:\n\t%s\n", join("\n\t", @purged)) if ($opts{verbose}); my $deleted = delete_volumes(@purged); print "$deleted volumes deleted.\n" if ($opts{verbose}); } elsif ($opts{verbose}) { print "No purged volumes found to delete.\n"; } print $IN "exit\n"; waitpid($pid, 0); exit (0); sub check_volumes { my $dividers = 0; my (@purged, @row); print $IN "list volumes pool=Scratch\n"; for (;;) { my $resp = <$OUT>; last if ($resp =~ /No results to list./); $dividers++ if ($resp =~ /^[\+\-]+$/); last if ($dividers == 3); @row = split(/\s+/, $resp); push (@purged, $row[3]) if ($row[5] eq 'Purged'); } return (@purged); } sub delete_volumes { my $volume_dir = '/spool/bacula/'; my $count = 0; foreach my $vol (@_) { my $l; my $file = $volume_dir.$vol; print "Deleting volume $vol from catalog ... " if ($opts{verbose}); print $IN "delete volume=$vol yes\n"; $l = <$OUT>; $l = <$OUT>; print "Done.\nDeleting volume $file from disk ... " if ($opts{verbose}); if (-f $file) { $count++; unlink ($file); } print "Done.\n" if ($opts{verbose}); } return ($count); } -- Phil Stracchino Babylon Communications ph...@caerllewys.net p...@co.ordinate.org Landline: 603.293.8485 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ Bacula-users mailing list Bacula-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bacula-users