On 11/05/12 11:02, John Doe wrote: > Hi, > > I am using bacula 2.4.2 to backup on a USB disk and... I am running a bit > out of space on the disk. So I switch from a 12 months full volume > retention to an 8 months one: > Recycle = yes > AutoPrune = yes > Volume Retention = 8 months > But, as I understand it, bacula will just reuse more often the full > backup volume files that already exist and will not remove any no more > needed ones... right? > Is there a way to recover a bit of space by deleting those (no more > needed ones)? > > By example, I have: > -rw-r----- 1 bacula disk 328533721 Nov 4 10:03 pc-03.full.v15 > -rw-r----- 1 bacula disk 4199989075 Nov 4 10:02 pc-03.full.v14 > -rw-r----- 1 bacula disk 847382551 Oct 9 22:31 pc-03.full.v29 > -rw-r----- 1 bacula disk 4199989051 Oct 9 22:29 pc-03.full.v28 > -rw-r----- 1 bacula disk 4012401582 Sep 2 04:19 pc-03.full.v27 > -rw-r----- 1 bacula disk 23988964 Aug 5 04:21 pc-03.full.v13 > -rw-r----- 1 bacula disk 4199989216 Aug 5 04:21 pc-03.full.v12 > -rw-r----- 1 bacula disk 4039486457 Jul 1 03:52 pc-03.full.v11 > -rw-r----- 1 bacula disk 3821819189 Jun 3 03:37 pc-03.full.v10 > -rw-r----- 1 bacula disk 1560637745 May 6 2012 pc-03.full.v9 > -rw-r----- 1 bacula disk 4199989186 May 6 2012 pc-03.full.v2 > -rw-r----- 1 bacula disk 1624984181 Apr 1 2012 pc-03.full.v1 > -rw-r----- 1 bacula disk 4199989215 Apr 1 2012 pc-03.full.v0 > -rw-r----- 1 bacula disk 1001527717 Mar 4 2012 pc-03.full.v8 > -rw-r----- 1 bacula disk 4199989117 Mar 4 2012 pc-03.full.v7 > -rw-r----- 1 bacula disk 2319064239 Feb 5 2012 pc-03.full.v6 > -rw-r----- 1 bacula disk 4199989173 Feb 5 2012 pc-03.full.v5 > -rw-r----- 1 bacula disk 2387887814 Jan 1 2012 pc-03.full.v4 > -rw-r----- 1 bacula disk 4199989267 Jan 1 2012 pc-03.full.v3 > -rw-r----- 1 bacula disk 2218494763 Dec 4 2011 pc-03.full.v26 > -rw-r----- 1 bacula disk 4199989203 Dec 4 2011 pc-03.full.v25 > -rw-r----- 1 bacula disk 2294915926 Nov 6 2011 pc-03.full.v24 > -rw-r----- 1 bacula disk 4199989068 Nov 6 2011 pc-03.full.v23 > -rw-r----- 1 bacula disk 4045159515 Oct 2 2011 pc-03.full.v22 > -rw-r----- 1 bacula disk 4199989165 Oct 2 2011 pc-03.full.v21 > -rw-r----- 1 bacula disk 4199989224 Oct 2 2011 pc-03.full.v20 > -rw-r----- 1 bacula disk 92492816 Sep 4 2011 pc-03.full.v19 > -rw-r----- 1 bacula disk 4199988959 Sep 4 2011 pc-03.full.v18 > -rw-r----- 1 bacula disk 4199989250 Sep 4 2011 pc-03.full.v17 > -rw-r----- 1 bacula disk 4199989299 Sep 4 2011 pc-03.full.v16 > the files v16-26 and more or less v3-v6 are more than 8 months old... > > I am a bit afraid of using the purge/delete commands in an incorrect way...
The short answer: Purge and delete the volumes you no longer need, then delete them from disk. I have a script that does precisely this. The basic logic is to set the action on purge to move the volume into the Scratch pool, then have an admin job that periodically lists the disk volumes in the Scratch pool, deletes them from the catalog, and removes the disk files. Here's my setup. I have three active pools: Full-Tape, Diff-Disk, and Incr-Disk. Differentials are retained for two months (spanning two Full backups to tape), incrementals for one month (spanning four Differentials). Disk volumes are autolabeled as needed, used for one day, and recycled into the Scratch pool when pruned or purged: Pool { Name = Diff-Disk Storage = babylon4-file Pool Type = Backup Recycle = no Recycle Oldest Volume = no Recycle Current Volume = no AutoPrune = yes Volume Retention = 2 months Maximum Volume Jobs = 0 Volume Use Duration = 23h Label Format = "DIFF-$Year${Month:p/2/0/r}${Day:p/2/0/r}-${Hour:p/2/0/r}:${Minute:p/2/0/r}" RecyclePool = Scratch } 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 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 } Once a week, this admin job runs: 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" } This is the script it executes: #!/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); 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, CDK#2 DoD#299792458 ICBM: 43.5607, -71.355 ala...@caerllewys.net ala...@metrocast.net p...@co.ordinate.org Renaissance Man, Unix ronin, Perl hacker, SQL wrangler, Free Stater It's not the years, it's the mileage. ------------------------------------------------------------------------------ LogMeIn Central: Instant, anywhere, Remote PC access and management. Stay in control, update software, and manage PCs from one command center Diagnose problems and improve visibility into emerging IT issues Automate, monitor and manage. Do more in less time with Central http://p.sf.net/sfu/logmein12331_d2d _______________________________________________ Bacula-users mailing list Bacula-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/bacula-users