Bacula Tape Restore Without Database

Hi, In my work i got to make big restore from tape, but i didn’t had the jobs and volumes inserted on the database.

This post explains what i did  and the differents approaches you can do to solve that.

1.  I have 20 LTO4 Volumes Tapes
2. I need to do i full restore to directory
3. I don’t have in the database catalog that same volumes and jobs ids
4. I cannot disable by Bacula Backups Server to make the restore.

How to recover ?

1. plan get use of  bacula volume utility tools !!!!
2. Put the Tape Volumes inside you Tape Library
3. Get the Slots numbers of that tapes that you want to recover.
4. The most important – Create i bootstrap File.
If you create the bootstrap file its easier to use the bacula volume utility tools
My Bootstrap file looks Like this :

01
02
03
04
05
06
07
08
09
10
11
12
Volume="DWB132L4"
MediaType="LTO-4"
Slot=2
Volume="DWB133L4"
MediaType="LTO-4"
Slot=3
Volume="DWB134L4"
MediaType="LTO-4"
Slot=4
Volume="DWB135L4"
MediaType="LTO-4"
Slot=5

5. If you want to extract all your volumes just use this comand

1
bextract -b bootstrap.bsr -V DWB132L4\|DWB133L4\|DWB134L4\|DWB135L4\|DWB136L4\|DWB137L4\|DWB138L4\|DWB139L4\|DWB140L4\|DWB141L4\|DWB142L4\|DWB143L4\DWB144L4\|DWB145L4\| -v -c bacula-sd.conf /dev/tape3 /destinationdir

And voila that’s it you can extract all volumes. But this away there some problems, bextract does not extract the acls files permissions.

Another Approach

Another away is using bscan to repopulate your catalog database.

1. Create Bootstrap file same has above
2. Use the command

1
bscan -b bscan.bsr -V DWB132L4\|DWB133L4\|DWB134L4\|DWB135L4\|DWB136L4\|DWB137L4\|DWB138L4\|DWB139L4\|DWB140L4\|DWB141L4\|DWB142L4\|DWB143L4\DWB144L4\|DWB145L4\| -v -s -m -c bacula-sd.conf /dev/tape3

But there is one problem with this approach, bacula appends the new volumes and jobs ids to the default pool, if you had or want this volumes on different pool its better you have i new clean catalog and import the volumes. After you can choose the jobid and restore the files.

Imagine that you only want i specify jobid ?

1. Create Bootstrap file same has above
2. First you can try to check what jobs,files contain the tape with the command bls, for example:

1
bls -j -V Test1 /dev/tape3

3. This command try to read the tape inside st0 with the volume Test1 (label of your tape) and show a list of job inside the tape, like:

01
02
03
04
05
06
07
08
09
10
bls: butil.c:258 Using device: "DDS-4" for reading.
11-Jul 11:54 bls: Ready to read from volume "Test1" on device "DDS-4" (/dev/nst0).
Volume Record: File:blk=0:1 SessId=4 SessTime=1121074625 JobId=0 DataLen=165
Begin Job Session Record: File:blk=0:2 SessId=4 SessTime=1121074625 JobId=1 Level=F Type=B
Begin Job Session Record: File:blk=0:3 SessId=5 SessTime=1121074625 JobId=5 Level=F Type=B
Begin Job Session Record: File:blk=0:6 SessId=3 SessTime=1121074625 JobId=2 Level=F Type=B
Begin Job Session Record: File:blk=0:13 SessId=2 SessTime=1121074625 JobId=4 Level=F Type=B
End Job Session Record: File:blk=0:99 SessId=3 SessTime=1121074625 JobId=2 Level=F Type=B
Files=168 Bytes=1,732,978 Errors=0 Status=T
End Job Session Record: File:blk=0:101 SessId=2 SessTime=1121074625 JobId=4 Level=F Type=B

This information is very important later for restore exactly what we need, SessId and SessTime is our precious information.

Now that we collect enough information we can proceed to restore with the useful command bextract, but we need to tell what session or job to extract, how?
Simple, with bootstrap file, based on the example above we need to restore session 3 from the tape so we create a simple file for example named bootstrap.bsr, with something similar inside:

1
2
3
Volume = Test1
VolSessionId = 3
VolSessionTime = 1121074625

Finally we can extract safely our data with bextract with this command:

1
bextract -b bootstrap.bsr /dev/st0 /tmp

and voilà you have restored exactly what you need with only a tape.

Fuente: http://www.pedroliveira.pt/bacula-tape-restore-without-database/