The FreeBSD Diary

The FreeBSD Diary (TM)

Providing practical examples since 1998

If you buy from Amazon USA, please support us by using this link.
[ HOME | TOPICS | INDEX | WEB RESOURCES | BOOKS | CONTRIBUTE | SEARCH | FEEDBACK | FAQ | FORUMS ]

Things look quiet here. But I've been doing a lot of blogging at dan.langille.org because I prefer WordPress now. Not all my posts there are FreeBSD related. I am in the midst of migrating The FreeBSD Diary over to WordPress (and you can read about that here). Once the migration is completed, I'll move the FreeBSD posts into the new FreeBSD Diary website.

Bacula - Sony SDT 10000 1 June 2004
Need more help on this topic? Click here
This article has 1 comment
Show me similar articles

Bacula is the network backup solution. I've been using since (just over a year). I'm pretty impressed with it. At BSDCan I was presented with a Sony STD 10000 DAT drive, a donation from a reader, which will help with my backups and with my work on Bacula. Backup solutions are many and varied. Make sure you choose the right backup software.

I'm assuming you know how to physically install your tape drive. After I installed my tape drive, I found it via dmesg:

sa0 at ahc0 bus 0 target 4 lun 0
sa0: <SONY SDT-10000 0101> Removable Sequential Access SCSI-2 device
sa0: 40.000MB/s transfers (20.000MHz, offset 8, 16bit)

No matter how good your software, you must test your hardware. So I'll start with that.

Testing the tape drive

We will test once without pthreads, and then again with pthreads. Both must finish with an error code of zero. This tests the operating system more than it does the tape drive. The goal of this test is to ensure that we do not lose data when a tape is filled.

I installed Bacula 1.34.2 from the ports tree:

cd /usr/ports/sysutils/bacula/
make install
Note that I did not do a clean. I will do that later. In the meantime, I wanted access to this directory (note that it would have been sufficient to do a make patch to get this code):
cd /usr/ports/sysutils/bacula/work/bacula-1.34.2/platforms/freebsd
In there, I wanted pthreads-fix.txt and tapetest.c. Following the instructions in the first file, I compiled and ran tapetest (for what it's worth, this was a DDS-3 tape):
c++ -g -O2 -Wall -c tapetest.c
c++ -g -O2 -Wall tapetest.o -o tapetest
./tapetest /dev/sa0
*rewind Rewound /dev/sa0 *rawfill Begin writing blocks of 64512 bytes. ++++++++++ insert 15 lines of 110 columns of annoying stuff +++++++
weof_dev
Wrote EOF to /dev/sa0
Write failed. Last block written=191305. stat=0 ERR=Unknown error: 0
*rewind
Rewound /dev/sa0
*scan
Starting scan at file 0
191305 blocks of 64512 bytes in file 0
End of File mark.
End of File mark.
End of tape
Total files=1, blocks=191305, bytes = -543433728
*

We have an error code of zero. Note also that the number of blocks written matches the number of blocks read. That too is important.

Now for the pthreads version of the test:

c++ -g -O2 -Wall -pthread -c tapetest.c
c++ -g -O2 -Wall -pthread tapetest.o -o tapetest
./tapetest /dev/sa0
*rewind
Rewound /dev/sa0
*rawfill
Begin writing blocks of 64512 bytes.
++++++++++ insert 15 lines of 110 columns of annoying stuff +++++++
weof_dev
Wrote EOF to /dev/sa0
Write failed. Last block written=191350. stat=0 ERR=Resource temporarily unavailable
*rewind
Rewound /dev/sa0
*scan
Starting scan at file 0
191350 blocks of 64512 bytes in file 0
End of File mark.
End of File mark.
End of tape
Total files=1, blocks=191350, bytes = -540530688
*

Again, that's good. We have the same number of blocks written and read. More importantly, the error code is zero (stat = 0). This test is especially important on FreeBSD because of the pthreads bug.

Configuration of the DDS-4 drive

The Bacula ports installs sample configuration files. In my case, I have installed the server onto my computer. I used the supplied Storage Daemon example configuration file as my starting point:

cd /usr/local/etc
cp bacula-sd.conf.sample bacula-sd.conf
I then used the existing "FreeBSD tape drive" as a starting point.  Here is what I'm using for my Sony SDT 10000 DAT drive:
Device {
 Name                    = SonySDT10000
 Description             = "DDS-4"
 Media Type              = DDS-4
 Archive Device          = /dev/nsa0
 AutomaticMount          = yes;
 AlwaysOpen              = yes
 Offline On Unmount      = no
 Hardware End of Medium  = no
 BSF at EOM              = yes
 Backward Space Record   = no
 Fast Forward Space File = no
 TWO EOF                 = yes
}

With this configuration, I started the test using the btape program supplied with Bacula. Is it essential that you perform this test before using Bacula. It can identify any potential problems you may have. There is more to tape backup than just writing data to the tape. Not all tape drives and operating systems behave the same. Bacula attempts to work with a wide variety of combinations. This testing program uses years of Bacula experience to help you around any pitfalls. If any problems are detected, Bacula will recommmend a configuration change. If necessary, please consult the Bacula Users mailing list for additional help.

/usr/local/sbin/btape -c /usr/local/etc/bacula-sd.conf /dev/nsa0
Tape block granularity is 1024 bytes.
btape: butil.c:164 Using device: "/dev/nsa0" for writing.
btape: btape.c:310 open_dev /dev/nsa0 OK
*test

=== Write, rewind, and re-read test ===

I'm going to write 1000 records and an EOF
then write 1000 records and an EOF, then rewind,
and re-read the data to verify that it is correct.

This is an *essential* feature ...

btape: btape.c:761 Wrote 1000 blocks of 64412 bytes.
btape: btape.c:442 Wrote 1 EOF to /dev/nsa0
btape: btape.c:777 Wrote 1000 blocks of 64412 bytes.
btape: btape.c:442 Wrote 1 EOF to /dev/nsa0
btape: btape.c:442 Wrote 1 EOF to /dev/nsa0
btape: btape.c:786 Rewind OK.
1000 blocks re-read correctly.
Got EOF on tape.
1000 blocks re-read correctly.
=== Test Succeeded. End Write, rewind, and re-read test ===


=== Write, rewind, and position test ===

I'm going to write 1000 records and an EOF
then write 1000 records and an EOF, then rewind,
and position to a few blocks and verify that it is correct.

This is an *essential* feature ...

btape: btape.c:869 Wrote 1000 blocks of 64412 bytes.
btape: btape.c:442 Wrote 1 EOF to /dev/nsa0
btape: btape.c:885 Wrote 1000 blocks of 64412 bytes.
btape: btape.c:442 Wrote 1 EOF to /dev/nsa0
btape: btape.c:442 Wrote 1 EOF to /dev/nsa0
btape: btape.c:894 Rewind OK.
Reposition to file:block 0:4
Block re-read correctly.
Reposition to file:block 0:200
Block re-read correctly.
Reposition to file:block 0:999
Block re-read correctly.
Reposition to file:block 1:0
Block re-read correctly.
Reposition to file:block 1:600
Block re-read correctly.
Reposition to file:block 1:999
Block re-read correctly.
=== Test Succeeded. End Write, rewind, and re-read test ===



=== Append files test ===

This test is essential to Bacula.

I'm going to write one record  in file 0,
                   two records in file 1,
             and three records in file 2

btape: btape.c:412 Rewound /dev/nsa0
btape: btape.c:1448 Wrote one record of 64412 bytes.
btape: btape.c:1450 Wrote block to device.
btape: btape.c:442 Wrote 1 EOF to /dev/nsa0
btape: btape.c:1448 Wrote one record of 64412 bytes.
btape: btape.c:1450 Wrote block to device.
btape: btape.c:1448 Wrote one record of 64412 bytes.
btape: btape.c:1450 Wrote block to device.
btape: btape.c:442 Wrote 1 EOF to /dev/nsa0
btape: btape.c:1448 Wrote one record of 64412 bytes.
btape: btape.c:1450 Wrote block to device.
btape: btape.c:1448 Wrote one record of 64412 bytes.
btape: btape.c:1450 Wrote block to device.
btape: btape.c:1448 Wrote one record of 64412 bytes.
btape: btape.c:1450 Wrote block to device.
btape: btape.c:442 Wrote 1 EOF to /dev/nsa0
btape: btape.c:442 Wrote 1 EOF to /dev/nsa0
btape: btape.c:412 Rewound /dev/nsa0
btape: btape.c:1003 Now moving to end of medium.
btape: dev.c:513 Adjust file from 3 to 4
btape: btape.c:459 Moved to end of medium.
We should be in file 3. I am at file 3. This is correct!

Now the important part, I am going to attempt to append to the tape.

btape: btape.c:1448 Wrote one record of 64412 bytes.
btape: btape.c:1450 Wrote block to device.
btape: btape.c:442 Wrote 1 EOF to /dev/nsa0
btape: btape.c:442 Wrote 1 EOF to /dev/nsa0
btape: btape.c:412 Rewound /dev/nsa0
Done appending, there should be no I/O errors

Doing Bacula scan of blocks:
1 block of 64448 bytes in file 1
End of File mark.
2 blocks of 64448 bytes in file 2
End of File mark.
3 blocks of 64448 bytes in file 3
End of File mark.
1 block of 64448 bytes in file 4
End of File mark.
Total files=4, blocks=7, bytes = 451,136
End scanning the tape.
We should be in file 4. I am at file 4. This is correct!

The above Bacula scan should have output identical to what follows.
Please double check it ...
=== Sample correct output ===
1 block of 64448 bytes in file 1
End of File mark.
2 blocks of 64448 bytes in file 2
End of File mark.
3 blocks of 64448 bytes in file 3
End of File mark.
1 block of 64448 bytes in file 4
End of File mark.
Total files=4, blocks=7, bytes = 451,136
=== End sample correct output ===

If the above scan output is not identical to the
sample output, you MUST correct the problem
or Bacula will not be able to write multiple Jobs to
the tape.

Skipping read backwards test because BSR turned off.


=== Forward space files test ===

This test is essential to Bacula.

I'm going to write five files then test forward spacing

btape: btape.c:412 Rewound /dev/nsa0
btape: btape.c:1448 Wrote one record of 64412 bytes.
btape: btape.c:1450 Wrote block to device.
btape: btape.c:442 Wrote 1 EOF to /dev/nsa0
btape: btape.c:1448 Wrote one record of 64412 bytes.
btape: btape.c:1450 Wrote block to device.
btape: btape.c:1448 Wrote one record of 64412 bytes.
btape: btape.c:1450 Wrote block to device.
btape: btape.c:442 Wrote 1 EOF to /dev/nsa0
btape: btape.c:1448 Wrote one record of 64412 bytes.
btape: btape.c:1450 Wrote block to device.
btape: btape.c:1448 Wrote one record of 64412 bytes.
btape: btape.c:1450 Wrote block to device.
btape: btape.c:1448 Wrote one record of 64412 bytes.
btape: btape.c:1450 Wrote block to device.
btape: btape.c:442 Wrote 1 EOF to /dev/nsa0
btape: btape.c:1448 Wrote one record of 64412 bytes.
btape: btape.c:1450 Wrote block to device.
btape: btape.c:1448 Wrote one record of 64412 bytes.
btape: btape.c:1450 Wrote block to device.
btape: btape.c:442 Wrote 1 EOF to /dev/nsa0
btape: btape.c:1448 Wrote one record of 64412 bytes.
btape: btape.c:1450 Wrote block to device.
btape: btape.c:442 Wrote 1 EOF to /dev/nsa0
btape: btape.c:442 Wrote 1 EOF to /dev/nsa0
btape: btape.c:412 Rewound /dev/nsa0
btape: btape.c:1210 Now forward spacing 1 file.
We should be in file 1. I am at file 1. This is correct!
btape: btape.c:1222 Now forward spacing 2 files.
We should be in file 3. I am at file 3. This is correct!
btape: btape.c:412 Rewound /dev/nsa0
btape: btape.c:1235 Now forward spacing 4 files.
We should be in file 4. I am at file 4. This is correct!

btape: btape.c:1253 Now forward spacing 1 more file.
We should be in file 5. I am at file 5. This is correct!

=== End Forward space files test ===

*

The above may look like a bunch of useless trivia, but please believe that it is necessary. In this case, there are no recommendations

Getting the Bacula console running

Bacula supplies sample configuration files in /usr/local/etc/. They are:

[root@polo:/usr/local/etc] # ls -l bacula-*sample*
-r--r--r--  1 root  wheel   949 May 25 14:08 bacula-barcodes.samples
-rw-r-----  1 root  wheel  6096 May 25 14:08 bacula-dir.conf.sample
-rw-r-----  1 root  wheel   743 May 25 14:08 bacula-fd.conf.sample
-rw-r-----  1 root  wheel  2815 May 25 14:08 bacula-sd.conf.sample
I used those as starting points (NOTE: be careful not to overwrite any existing files! <== that's why you see the -i below):
cp -i bacula-dir.conf.sample bacula-dir.conf
cp -i bacula-fd.conf.sample  bacula-fd.conf
cp -i bacula-sd.conf.sample  bacula-sd.conf

These configuration files are set up to do a backup of the working directory from which Bacula was installed. In my case, that will be /usr/ports/sysutils/bacula/work/bacula-1.34.2. You can verify your own default backup job by inspecting /usr/local/etc/bacula-dir.conf and looking for the FileSet resource with a Name of "Full Set".

Now that we have our configuration files set, it's time to get into the Bacula console and run the default backup job.

$ /usr/local/sbin/bconsole -c /usr/local/etc/bconsole.conf
Connecting to Director polo:9101
1000 OK: polo-dir Version: 1.34.2 (24 Apr 2004)
Enter a period to cancel a command.
*

Query the Director's status:

Using default Catalog name=MyCatalog DB=bacula
polo-dir Version: 1.34.2 (24 Apr 2004) i386-portbld-freebsd4.9 freebsd 4.9-STABLE
Daemon started 26-May-04 09:17, 0 Jobs run since started.

Scheduled Jobs:
Level          Type    Scheduled          Name              Volume
===============================================================================
Incremental    Backup  27-May-04 01:05    Client1           *unknown*
Full           Backup  27-May-04 01:10    BackupCatalog     *unknown*
====
Running Jobs:
No Jobs running.
====
No Terminated Jobs.
====

Nothing suspicious there. OK, let's see if our client File Daemon is running:

*st client
Automatically selected Client: polo-fd
Connecting to Client polo-fd at polo:9102
Failed to connect to Client polo-fd.
====
You have messages.
*

Oh, err, ummm, that's not good. What are our messages?

*mes
26-May-2004 09:50 polo-dir: *Console*.2004-05-26_09.49.56 Fatal error: Director and File daemon passwords or names not the same.
*

OK, let's get out of the Console and check the passwords ( Q will quit the console). These are the two sections you need to look for.

/usr/local/etc/bacula-fd.conf

Director {   Name = polo-dir
  Password = "/PEACSf/ZnF9KTeDd6WcX/WBsFOQE/drgS48CjC" }

/usr/local/etc/bacula-dir.conf

Client {
  Name = polo-fd
  Address = polo
  FDPort = 9102
  Catalog = MyCatalog
  Password = "Gu9VX10Cbx26mZMd0T6FlEk8Z3g7Sle+SCBBmfj"
  ...

It is quite clear that the two passwords are not the same. I fixed that and then restarted the daemons:

# /usr/local/etc/rc.d/bacula.sh restart
Stopping the File daemon
Stopping the Storage daemon
Stopping the Director daemon

Starting the Storage daemon
Starting the File daemon
Starting the Director daemon

Now if I query the client, I get the expected results:

*st
Status available for:
     1: Director
     2: Storage
     3: Client
     4: All
Select daemon type for status (1-4): 3
Automatically selected Client: polo-fd
Connecting to Client polo-fd at polo:9102

polo-fd Version: 1.34.2 (24 Apr 2004) i386-portbld-freebsd4.9 freebsd 4.9-STABLE
Daemon started 26-May-04 10:00, 0 Jobs run since started.
No Terminated Jobs.
Running Jobs:
Director connected at: 26-May-04 10:04
No Jobs running.
====
*

OK, now I think we're ready to run our first job.

Running the first job

The console is used to run a job manually:

*run
Using default Catalog name=MyCatalog DB=bacula
A job name must be specified.
The defined Job resources are:
     1: Client1
     2: BackupCatalog
     3: RestoreFiles
Select Job resource (1-3): 1

Client1 is the name assigned to the computer onto which Bacula is installed. You may change this name if you wish. We will backup that client so we select the corresponding option.

Run Backup job
JobName:  Client1
FileSet:  Full Set
Level:    Incremental
Client:   polo-fd
Storage:  File
Pool:     Default
When:     2004-05-26 10:08:31
Priority: 10
OK to run? (yes/mod/no): yes
Run command submitted.
*

That's it. The job should be running now. We are backing up to File, not Tape as showng by the Storage parameter. Press ENTER and you should be told that you have messages.

*
You have messages.
*mes
26-May-2004 10:08 polo-dir: Created new FileSet record "Full Set" 2004-05-26 10:08:55
26-May-2004 10:08 polo-dir: No prior Full backup Job record found.
26-May-2004 10:08 polo-dir: No prior or suitable Full backup found. Doing FULL backup.
26-May-2004 10:08 polo-dir: Start Backup JobId 1, Job=Client1.2004-05-26_10.08.53
26-May-2004 10:09 polo-sd: Job Client1.2004-05-26_10.08.53 waiting. Cannot find any appendable volumes.
Please use the "label"  command to create a new Volume for:
    Storage:      FileStorage
    Media type:   File
    Pool:         Default
*

DOH! We didn't create a Volume for Bacula to use. Let's create one now.

*label
Automatically selected Storage: File
Enter new Volume name: TestVolume001
Automatically selected Pool: Default
Connecting to Storage daemon File at polo:9103 ...
Sending label command for Volume "TestVolume001" Slot 0 ...
3000 OK label. Volume=TestVolume001 Device=/tmp
Catalog record for Volume "TestVolume001", Slot 0 successfully created.
Requesting to mount FileStorage ...
3001 OK mount. Device=/tmp
*

If you press ENTER now, you should see something like this:

*
You have messages.
*mess
26-May-2004 10:17 polo-sd: Wrote label to prelabeled Volume "TestVolume001" on device "/tmp"
26-May-2004 10:17 polo-dir: Bacula 1.34.2 (24Apr04): 26-May-2004 10:17
JobId:                  1
Job:                    Client1.2004-05-26_10.08.53
Backup Level:           Full (upgraded from Incremental)
Client:                 polo-fd
FileSet:                "Full Set" 2004-05-26 10:08:55
Start time:             26-May-2004 10:08
End time:               26-May-2004 10:17
FD Files Written:       1,139
SD Files Written:       1,139
FD Bytes Written:       12,612,042
SD Bytes Written:       12,788,221
Rate:                   25.3 KB/s
Software Compression:   None
Volume name(s):         TestVolume001
Volume Session Id:      1
Volume Session Time:    1085580043
Last Volume Bytes:      12,837,194
Non-fatal FD errors:    0
SD Errors:              0
FD termination status:  OK
SD termination status:  OK
Termination:            Backup OK

26-May-2004 10:17 polo-dir: Begin pruning Jobs.
26-May-2004 10:17 polo-dir: No Jobs found to prune.
26-May-2004 10:17 polo-dir: Begin pruning Files.
26-May-2004 10:17 polo-dir: No Files found to prune.
26-May-2004 10:17 polo-dir: End auto prune.

*

If you see something simliar to that, then all went well.

Now, let's Verify that job. A verify ensures that the data on the tape matches the data on the Volume. There is no default Verify job in the Bacula configuration. I will create one now by adding the following to the Bacula Director configuration file:

Job {
  Name     = "Verify"
  JobDefs  = "DefaultJob"
  Type     = Verify
  Level    = Catalog
}

After restarting the Bacula daemons (actually, only the Director needs to be restarted here), we can now run that Verify job.

*run
Using default Catalog name=MyCatalog DB=bacula
A job name must be specified.
The defined Job resources are:
     1: Client1
     2: BackupCatalog
     3: RestoreFiles
     4: Verify
Select Job resource (1-4): 4
Run Verify job
JobName:     Verify
FileSet:     Full Set
Level:       Catalog
Client:      polo-fd
Storage:     File
Pool:        Default
Verify Job:
When:        2004-05-26 10:31:36
Priority:    10
OK to run? (yes/mod/no): yes
Run command submitted.
*

After pressing ENTER, you should see this:

*messages
26-May-2004 10:31 polo-dir: Verify.2004-05-26_10.31.40 Fatal error: Unable to find JobId of previous InitCatalog Job.
Please run a Verify with Level=InitCatalog before
running the current Job.
26-May-2004 10:31 polo-dir: Verify.2004-05-26_10.31.40 Error: Bacula 1.34.2 (24Apr04): 26-May-2004 10:31
JobId:                  2
Job:                    Verify.2004-05-26_10.31.40
FileSet:                Full Set
Verify Level:           Catalog
Client:                 polo-fd
Verify JobId:           0
Verify Job:
Start time:             26-May-2004 10:31
End time:               26-May-2004 10:31
Files Examined:         0
Non-fatal FD errors:    0
FD termination status:
Termination:            *** Verify Error ***

*

DOH (again)! We haven't run an InitCatalog yet. Let's do that now.

*run
A job name must be specified.
The defined Job resources are:
     1: Client1
     2: BackupCatalog
     3: RestoreFiles
     4: Verify
Select Job resource (1-4): 4
Run Verify job
JobName:     Verify
FileSet:     Full Set
Level:       Catalog
Client:      polo-fd
Storage:     File
Pool:        Default
Verify Job:
When:        2004-05-26 10:37:12
Priority:    10
OK to run? (yes/mod/no): mod
Parameters to modify:
     1: Level
     2: Storage
     3: Job
     4: FileSet
     5: Client
     6: When
     7: Priority
     8: Pool
     9: Verify Job
Select parameter to modify (1-9): 1
Levels:
     1: Initialize Catalog
     2: Verify Catalog
     3: Verify Volume to Catalog
     4: Verify Disk to Catalog
     5: Verify Volume Data (not yet implemented)
Select level (1-5): 1
Run Verify job
JobName:     Verify
FileSet:     Full Set
Level:       InitCatalog
Client:      polo-fd
Storage:     File
Pool:        Default
Verify Job:
When:        2004-05-26 10:37:12
Priority:    10
OK to run? (yes/mod/no): yes
Run command submitted.
*mes
26-May-2004 10:37 polo-dir: Start Verify JobId 3 Job=Verify.2004-05-26_10.37.27
26-May-2004 10:37 polo-dir: Bacula 1.34.2 (24Apr04): 26-May-2004 10:37
JobId:                  3
Job:                    Verify.2004-05-26_10.37.27
FileSet:                Full Set
Verify Level:           InitCatalog
Client:                 polo-fd
Verify JobId:           0
Verify Job:
Start time:             26-May-2004 10:37
End time:               26-May-2004 10:37
Files Examined:         1,139
Non-fatal FD errors:    0
FD termination status:  OK
Termination:            Verify OK

26-May-2004 10:37 polo-dir: Begin pruning Jobs.
26-May-2004 10:37 polo-dir: No Jobs found to prune.
26-May-2004 10:37 polo-dir: Begin pruning Files.
26-May-2004 10:37 polo-dir: No Files found to prune.
26-May-2004 10:37 polo-dir: End auto prune.

*

NOW our verify job should work.

*run
A job name must be specified.
The defined Job resources are:
     1: Client1
     2: BackupCatalog
     3: RestoreFiles
     4: Verify
Select Job resource (1-4): 4
Run Verify job
JobName:     Verify
FileSet:     Full Set
Level:       Catalog
Client:      polo-fd
Storage:     File
Pool:        Default
Verify Job:
When:        2004-05-26 10:41:14
Priority:    10
OK to run? (yes/mod/no): yes
Run command submitted.
*mes
26-May-2004 10:41 polo-dir: Start Verify JobId 4 Job=Verify.2004-05-26_10.41.19
26-May-2004 10:41 polo-dir: Verifying against JobId=3 Job=Verify.2004-05-26_10.37.27
26-May-2004 10:41 polo-dir: Bacula 1.34.2 (24Apr04): 26-May-2004 10:41
JobId:                  4
Job:                    Verify.2004-05-26_10.41.19
FileSet:                Full Set
Verify Level:           Catalog
Client:                 polo-fd
Verify JobId:           3
Verify Job:
Start time:             26-May-2004 10:41
End time:               26-May-2004 10:41
Files Examined:         1,139
Non-fatal FD errors:    0
FD termination status:  OK
Termination:            Verify OK

26-May-2004 10:41 polo-dir: Begin pruning Jobs.
26-May-2004 10:41 polo-dir: No Jobs found to prune.
26-May-2004 10:41 polo-dir: Begin pruning Files.
26-May-2004 10:41 polo-dir: No Files found to prune.
26-May-2004 10:41 polo-dir: End auto prune.

*

And yes, it does work properly.

Now we can try a backup to tape.

Backup to the DDS-4 drive

We can backup to the DDS-4 drive using an existing job. All we do is modify the Storage parameter.

*run
A job name must be specified.
The defined Job resources are:
1: Client1
2: BackupCatalog
3: RestoreFiles
4: Verify
Select Job resource (1-4): 1
Run Backup job
JobName: Client1
FileSet: Full Set
Level: Incremental
Client: polo-fd
Storage: File
Pool: Default
When: 2004-05-26 10:46:01
Priority: 10
OK to run? (yes/mod/no): mod
Parameters to modify:
1: Level
2: Storage
3: Job
4: FileSet
5: Client
6: When
7: Priority
8: Pool
Select parameter to modify (1-8): 2
Automatically selected Storage: File
Run Backup job
JobName: Client1
FileSet: Full Set
Level: Incremental
Client: polo-fd
Storage: File
Pool: Default
When: 2004-05-26 10:46:01
Priority: 10
OK to run? (yes/mod/no): no
Job not run.
*
Oh... There is only one option for Storage and Bacula has automatically chosen it for me. That means my configuration is lacking the specification for the DDS-4 tape drive. Let's fix that. I now I've added a section to the Storage Daemon configuration file /usr/local/etc/bacula-sd.conf but the Directory needs to know about it too. Let's fix that by adding the following to /usr/local/etc/bacula-dir.conf:
Storage {
  Name       = SonySDT10000
  Address    = polo.example.org
  SDPort     = 9103
  Password   = "x1m0u0Zk96bgYsTGh78SnCakOjg7XD"
  Device     = SonySDT10000
  Media Type = DDS-4
}

Things to note:

  • The Name field is what you see listed in the Console.
  • The Address is the IP address or, preferably, the hostname of the box on which the tape drive exists.
  • The Password must match that supplied in the /usr/local/etc/bacula-sd.conf file.
  • The Device field must match the Name field in the Device resource of the /usr/local/etc/bacula-sd.conf file.

Now I can run a status command on that Storage device:

*status storage=SonySDT10000
Using default Catalog name=MyCatalog DB=bacula
Connecting to Storage daemon SonySDT10000 at polo:9103

polo-sd Version: 1.34.2 (24 Apr 2004) i386-portbld-freebsd4.9 freebsd 4.9-STABLE
Daemon started 26-May-04 11:06, 0 Jobs run since started.

Running Jobs:
No Jobs running.
====

Terminated Jobs:
JobId  Level   Files          Bytes Status   Finished        Name
======================================================================
     1  Full      1,139     12,788,221 OK       26-May-04 10:17 Client1
     5  Incr          0              0 Error    26-May-04 10:53 Client1
====

Device status:
Device "/tmp" is not open.
Device "/dev/nsa0" open but no Bacula volume is mounted.
    Total Bytes Read=64,512 Blocks Read=1 Bytes/block=64,512
    Positioned at File=0 Block=0
====

Data spooling: 0 active jobs 0 bytes; 0 total jobs 0 max bytes/job.
Attr spooling: 0 active jobs; 0 total jobs 0 max bytes/job.
*

You can see that no Bacula volume is mounted. Ahh, let's not forget to label the Volume this time!

*label
The defined Storage resources are:
     1: File
     2: SonySDT10000
Select Storage resource (1-2): 2
Enter new Volume name: TestVolumeTape0001
Automatically selected Pool: Default
Connecting to Storage daemon SonySDT10000 at polo:9103 ...
Sending label command for Volume "TestVolumeTape0001" Slot 0 ...
3000 OK label. Volume=TestVolumeTape0001 Device=/dev/nsa0
Catalog record for Volume "TestVolumeTape0001", Slot 0  successfully created.
Requesting to mount SonySDT10000 ...
3001 Device /dev/nsa0 is mounted with Volume "TestVolumeTape0001"
*
And we can see all our volumes with this command:
*list media
Pool: Default
+---------+--------------------+-----------+------------+----------+--------------+---------+------+-----------+---------------------+
| mediaid | volumename         | volstatus | volbytes   | volfiles | volretention | recycle | slot | mediatype | lastwritten         |
+---------+--------------------+-----------+------------+----------+--------------+---------+------+-----------+---------------------+
|       1 | TestVolume001      | Append    | 12,837,194 |        0 |   31,536,000 |       1 |    0 | File      | 2004-05-26 10:17:13 |
|       2 | TestVolumeTape0001 | Append    |          1 |        0 |   31,536,000 |       1 |    0 | DDS-4     |                     |
+---------+--------------------+-----------+------------+----------+--------------+---------+------+-----------+---------------------+
*

Now for a backup to that new tape drive:

*run
A job name must be specified.
The defined Job resources are:
     1: Client1
     2: BackupCatalog
     3: RestoreFiles
     4: Verify
Select Job resource (1-4): 1
Run Backup job
JobName:  Client1
FileSet:  Full Set
Level:    Incremental
Client:   polo-fd
Storage:  File
Pool:     Default
When:     2004-05-26 11:17:17
Priority: 10
OK to run? (yes/mod/no): mod
Parameters to modify:
     1: Level
     2: Storage
     3: Job
     4: FileSet
     5: Client
     6: When
     7: Priority
     8: Pool
Select parameter to modify (1-8): 2
The defined Storage resources are:
     1: File
     2: SonySDT10000
Select Storage resource (1-2): 2
Run Backup job
JobName:  Client1
FileSet:  Full Set
Level:    Incremental
Client:   polo-fd
Storage:  SonySDT10000
Pool:     Default
When:     2004-05-26 11:17:17
Priority: 10
OK to run? (yes/mod/no): yes
Run command submitted.
*mes 26-May-2004 11:17 polo-dir: Start Backup JobId 6, Job=Client1.2004-05-26_11.17.26
26-May-2004 11:17 polo-sd: Wrote label to prelabeled Volume "TestVolumeTape0001" on device "/dev/nsa0"
26-May-2004 11:17 polo-dir: Bacula 1.34.2 (24Apr04): 26-May-2004 11:17
JobId:                  6
Job:                    Client1.2004-05-26_11.17.26
Backup Level:           Incremental, since=2004-05-26 10:08:55
Client:                 polo-fd
FileSet:                "Full Set" 2004-05-26 10:08:55
Start time:             26-May-2004 11:17
End time:               26-May-2004 11:17
FD Files Written:       0
SD Files Written:       0
FD Bytes Written:       0
SD Bytes Written:       0
Rate:                   0.0 KB/s
Software Compression:   None
Volume name(s):         TestVolumeTape0001
Volume Session Id:      1
Volume Session Time:    1085584261
Last Volume Bytes:      373
Non-fatal FD errors:    0
SD Errors:              0
FD termination status:  OK
SD termination status:  OK
Termination:            Backup OK

26-May-2004 11:17 polo-dir: Begin pruning Jobs.
26-May-2004 11:17 polo-dir: No Jobs found to prune.
26-May-2004 11:17 polo-dir: Begin pruning Files.
26-May-2004 11:17 polo-dir: No Files found to prune.
26-May-2004 11:17 polo-dir: End auto prune.

*

After running that job, here's what list media looks like:

+---------+--------------------+-----------+------------+----------+--------------+---------+------+-----------+---------------------+
| mediaid | volumename         | volstatus | volbytes   | volfiles | volretention | recycle | slot | mediatype | lastwritten         |
+---------+--------------------+-----------+------------+----------+--------------+---------+------+-----------+---------------------+
|       1 | TestVolume001      | Append    | 12,837,194 |        0 |   31,536,000 |       1 |    0 | File      | 2004-05-26 10:17:13 |
|       2 | TestVolumeTape0001 | Append    |        373 |        1 |   31,536,000 |       1 |    0 | DDS-4     | 2004-05-26 11:17:47 |
+---------+--------------------+-----------+------------+----------+--------------+---------+------+-----------+---------------------+

The volbytes for TestVolumeTape0001 may seem low. But I think we can up that a bit by doing a full backup as opposed to an incremental. And yes, my testing put that value up to 12,837,566 bytes after running a full backup.

OK, what now?

This tells me that Bacula is running as expected. The next step is making sure that Catalog backups are working. This can be done with a manual job run. Then I want to see thta scheduled jobs run as expected. For this I will leave Bacula running over night.

I ran the BackupCatalog job. Unfortunately, I got this error:

polo-dir: RunBefore: User name: pg_dump: too many command-line arguments (first is "bacula")
polo-dir: RunBefore: Try "pg_dump --help" for more information.
polo-dir: BackupCatalog.2004-05-26_15.37.09 Fatal error: RunBeforeJob returned non-zero status=10

Fortunately, I know how to correct this error. Examination of the Director's configuration file will show that the RunBeforeJob in the BackupCatalog job is

RunBeforeJob = "/usr/local/share/bacula/make_catalog_backup -u bacula"

I modified that statement and changed the -u to a -U. I'm using PostgreSQL, not MySQL. I've raised this issue and hopefully we'll get it resolved soon.

Now when I run the BackupCatalog job, it runs to completion.

I will now wait overnight for the regular jobs to run.

The Day After Tomorrow

Actually, it was a few days... It took a while to figure this one out. Actually, it took someone else to figure out the problem. The backup job ran properly. The verify job did not. It failed with this output:

From:           root@localhost.example.org (Bacula)
Subject:        Bacula: Verify Fatal Error of polo-fd Incremental
To:             root@localhost.example.org
Date sent:      Thu, 27 May 2004 01:05:13 -0400

polo-dir: Start Verify JobId 17 Job=Verify.2004-05-27_01.05.01
polo-dir: Verify.2004-05-27_01.05.01 Fatal error: verify.c:293 Unimplemented save level 73
polo-dir: Verify.2004-05-27_01.05.01 Error: Bacula 1.34.2 (24Apr04): 27-May-2004 01:05
JobId:                  17
Job:                    Verify.2004-05-27_01.05.01
FileSet:                Full Set
Verify Level:           Incremental
Client:                 polo-fd
Verify JobId:           0
Verify Job:            
Start time:             27-May-2004 01:05
End time:               27-May-2004 01:05
Files Examined:         0
Non-fatal FD errors:    0
FD termination status: 
Termination:            *** Verify Error ***

My first clue should have been the Verify Level. It was incremental. That is also the default job level for the schedule we used (DefaultJob). Thanks to Kern for pointing this out. To fix this, I created a new schedule:

Schedule {
  Name = "WeeklyCycleVerify"
  Run  = sun-sat at 11:10
}

This runs as expected.

Migrating from MySQL to PosgreSQL
This installation of Bacula used PostgreSQL. My production Bacula server uses MySQL. My next job is to move PostgreSQL into production and retire Bacula. That will be in my next article.

Share
Need more help on this topic? Click here
This article has 1 comment
Show me similar articles