Category: Backups

Nov 06

Bacula Relabel Tape

Some notes on what I did to erase a tape in Bacula.

unmount using bconsole

*unmount
The defined Storage resources are:
     1: File
     2: Scalar
Select Storage resource (1-2): 2
3307 Issuing autochanger "unload slot 2, drive 0" command.
3001 Device ""Drive-1" (/dev/nst0)" unmounted.

I used the library web front-end to move the tape into this drive then erased the label using operating system command mt:

root@bcla001:~# mt -f /dev/st0 rewind && mt -f /dev/st0 weof && mt -f /dev/st0 rewind

Manually label tape using bconsole. You probably want to use barcode labeling though. Look further down in this post.

*label
The defined Storage resources are:
     1: File
     2: Scalar
Select Storage resource (1-2): 2
Enter new Volume name: FullTest0002
Enter slot (0 or Enter for none): 
Defined Pools:
     1: Default
     2: File
     3: Scratch
     4: FullTest
     5: AllIncrementals
     6: AllDifferentials
     7: DiffTest
     8: IncrTest
Select the Pool (1-8): 4
Connecting to Storage daemon Scalar at bcla001:9103 ...
Sending label command for Volume "FullTest0002" Slot 0 ...
No slot defined in catalog (slot=0) for Volume "" on "Drive-1" (/dev/nst0).
Cartridge change or "update slots" may be required.
3301 Issuing autochanger "loaded? drive 0" command.
3302 Autochanger "loaded? drive 0", result is Slot 2.
3000 OK label. VolBytes=64512 DVD=0 Volume="FullTest0002" Device="Drive-1" (/dev/nst0)
Requesting to mount Drive-1 ...
3001 Device ""Drive-1" (/dev/nst0)" is mounted with Volume "FullTest0002"

check status using bconsole:

*status jobid=6
Connecting to Storage daemon Scalar at bcla001:9103

bcla001-sd Version: 5.2.6 (21 February 2012) x86_64-pc-linux-gnu debian wheezy/sid
Daemon started 07-Sep-12 17:37. Jobs: run=2, running=0.
 Heap: heap=589,824 smbytes=296,475 max_bytes=460,222 bufs=128 max_bufs=142
 Sizes: boffset_t=8 size_t=8 int32_t=4 int64_t=8 mode=0,0

Running Jobs:
Writing: Full Backup job Test JobId=6 Volume="FullTest0002"
    pool="FullTest" device="Drive-1" (/dev/nst0)
    spooling=0 despooling=0 despool_wait=0
    Files=1,047,529 Bytes=1,862,098,892,915 Bytes/sec=36,129,899
    FDReadSeqNo=36,562,344 in_msg=33718333 out_msg=5 fd=4
====
...snip
====

Device status:
Autochanger "Autochanger" with devices:
   "Drive-1" (/dev/nst0)
Device "FileStorage" is not open or does not exist.
Device "Drive-1" (/dev/nst0) is mounted with:
    Volume:      FullTest0002
    Pool:        FullTest
    Media type:  Ultrium5-SCSI
    Slot 2 is loaded in drive 0.
    Total Bytes=758,596,608 Blocks=11,758 Bytes/block=64,517
    Positioned at File=0 Block=11,759
====

Used Volume status:
FullTest0002 on device "Drive-1" (/dev/nst0)
    Reader=0 writers=1 devres=0 volinuse=1
====

====

Label using the barcode on the tape.

*label barcodes slot=11
The defined Storage resources are:
     1: File
     2: Scalar
Select Storage resource (1-2): 2
Connecting to Storage daemon Scalar at bcla001:9103 ...
3306 Issuing autochanger "slots" command.
Device "Drive-1" has 30 slots.
Connecting to Storage daemon Scalar at bcla001:9103 ...
3306 Issuing autochanger "list" command.
The following Volumes will be labeled:
Slot  Volume
==============
  11  VOL021
Do you want to label these Volumes? (yes|no): yes
Defined Pools:
     1: Default
     2: File
     3: Scratch
     4: FullTest
     5: AllIncrementals
     6: AllDifferentials
     7: DiffTest
     8: IncrTest
Select the Pool (1-8): 1
Connecting to Storage daemon Scalar at bcla001:9103 ...
Sending label command for Volume "VOL021" Slot 11 ...
3301 Issuing autochanger "loaded? drive 0" command.
3302 Autochanger "loaded? drive 0", result: nothing loaded.
3304 Issuing autochanger "load slot 11, drive 0" command.

Comments Off on Bacula Relabel Tape
comments

Nov 06

Recover Bacula Catalog Database After Accidental Purge of Jobs

I accidentally purged jobs from the Bacula catalog.  I recovered by using the ASCII sql export from the previous day. I am using sqlite for the DB but mysql should work similar. Read through /etc/bacula/scripts/make_catalog_backup near the end for some breadcrumbs around database recovery.

I had the following jobs in the catalog before I screwed up.

root@bcla001:~# echo "list jobs" | bconsole | grep -i dracula
| 10    | job_dracula    | 2012-09-09 11:57:11 | B    | F     | 288319   | 2234447730266 | T         |
| 13    | job_dracula    | 2012-09-14 23:58:05 | B    | F     | 288563   | 2260608426041 | T         |
| 45    | job_dracula    | 2012-10-14 00:56:53 | B    | F     | 0        | 0             | f         |
| 46    | job_dracula    | 2012-10-14 01:07:35 | B    | F     | 0        | 0             | R         |

For some reason I thought I will cleanup a bunch of failed jobs in the catalog using purge. Hindsight is 20 / 20 as they say....

*purge 

This command can be DANGEROUS!!!

It purges (deletes) all Files from a Job,
JobId, Client or Volume; or it purges (deletes)
all Jobs from a Client or Volume without regard
to retention periods. Normally you should use the
PRUNE command, which respects retention periods.
You have the following choices:
     1: files
     2: jobs
     3: volume
Choose item to purge (1-3): 2
The defined Client resources are:
     1: bcla001-fd
     2: server002-fd
     3: dracula-fd
Select Client (File daemon) resource (1-3): 3
Begin purging jobs from Client "dracula-fd"
No Files found for client dracula-fd to purge from MyCatalog catalog.

Rebuild the DB as follow. Stopping bacula services first.

root@bcla001:/var/lib# /etc/init.d/bacula-director stop
[ ok ] Stopping Bacula Director...: bacula-dir.
root@bcla001:/var/lib# /etc/init.d/bacula-fd stop
[ ok ] Stopping Bacula File daemon...: bacula-fd.
root@bcla001:/var/lib# /etc/init.d/bacula-sd stop
[ ok ] Stopping Bacula Storage daemon...: bacula-sd.

root@bcla001:/var/lib# ps -ef | grep bacula

root@bcla001:/var/lib/bacula# mv bacula.db bacula.db.101312

root@bcla001:/var/lib/bacula# sqlite3 bacula.db < bacula.sql

root@bcla001:/var/lib/bacula# chown bacula.bacula bacula.db

root@bcla001:/var/lib/bacula# ls -lh bacula.db
-rw-r--r-- 1 bacula bacula 1.1G Oct 14 00:43 bacula.db

root@bcla001:/var/lib/bacula# /etc/init.d/bacula-sd start
[ ok ] Starting Bacula Storage daemon...: bacula-sd.
root@bcla001:/var/lib/bacula# /etc/init.d/bacula-fd start
[ ok ] Starting Bacula File daemon...: bacula-fd.
root@bcla001:/var/lib/bacula# /etc/init.d/bacula-director start
[ ok ] Starting Bacula Director...: bacula-dir.

root@bcla001:/var/lib/bacula# ps -ef | grep bacula
bacula    8961     1  0 00:46 ?        00:00:00 /usr/sbin/bacula-sd -c /etc/bacula/bacula-sd.conf -u bacula -g tape
root      9006     1  0 00:46 ?        00:00:00 /usr/sbin/bacula-fd -c /etc/bacula/bacula-fd.conf
bacula    9036     1  0 00:46 ?        00:00:00 /usr/sbin/bacula-dir -c /etc/bacula/bacula-dir.conf -u bacula -g bacula

Comments Off on Recover Bacula Catalog Database After Accidental Purge of Jobs
comments