2

I'm trying to configure Bacula to automatically recycle and use a random tape i put in the single LTO drive, but it seems to prefer the oldest backup tape despite it isn't in the drive. I already marked all tapes as "Used" and ensure the retention period is over.

The storage conf and the dir conf SD.conf

Device {
Name = LTO5
Archive Device = /dev/nst0
Device Type = Tape
Media Type = LTO-5
LabelMedia = yes
Random Access = no
#AutoChanger = yes
AutomaticMount = yes
AlwaysOpen = yes
RemovableMedia = yes
Maximum Concurrent Jobs = 1
LabelMedia = yes
Maximum File Size = 12G

DIR

Pool {
  Name = Default
  Pool Type = Backup
  Recycle = yes                       # Bacula can automatically recycle Volumes
  AutoPrune = yes                     # Prune expired volumes
  Volume Retention = 15 days  

I have been reading the documentation and it seems to say that the storage algorithm will prefer the in drive tape but i don't think i'm understanding it right.

Is there any way to force bacula to user the tape currently inside the drive??

carlinux
  • 113
  • 1
  • 2
  • 10

1 Answers1

0

So I found a solution using a before-job script.

I modified the dir.conf adding this line to the job

Run Before Job = "/etc/bacula/scripts/purgecurrenttape" 

and purgecurrenttape is like this.

#!/bin/bash
#mount the inside-drive tape
echo "mount storage=LTO5" |bconsole| grep " " >> /var/log/scrcintas.log
sleep 5
#get the name of the mounted tape.
cinta=$(echo "status storage=LTO5" | bconsole  |grep Volume: |awk '{print $2}')
if [[ $cinta == CINTA* ]]; #check things.... 
then
#purge tape. 
echo "purge volume=$cinta" | bconsole | grep " " >> /var/log/scrcintas.log
sleep
else
echo error >> /var/log/scrcintas.log
fi

This way, it always uses the purged tape despite the retention periods of the jobs or volumes.

carlinux
  • 113
  • 1
  • 2
  • 10