Dear Thomas,

Thanks,

These scripts were most helpful!

I've thought about a couple of solutions which bypass the manual modification 
to the permissions and the
issue where the restore is started before the pipe is created.  They go like 
this:

1) add to the bacula group the db2inst1 user and restart db2 so that db2 can 
read from the pipe.  I haven't tested
this as I'm not sure if the restore process requires write access to the 
fifo... in which case it won't be enough.
2) Instead of submitting only the db2 restore command as a background process, 
do something similar to
the following:

CUT------

#!/bin/bash
# db2bacula-restore-worker.sh
# This script is designed to be a background task with stdin redirected to 
/dev/null and stderr combined with
# stdout and then redirected to a log file.
# The log file can be catt'ed by the 'Run after client' option of bacula so 
that db2 output is captured along
# with the backup logs
#

# Wait somewhere around 2 minutes for the pipe to appear.
declare -i TIMELEFT=120

while ( [ $TIMELEFT -gt 0 ] && ! [ -p /tmp/bacula-fifo ] ) ; do
  TIMELEFT --
  sleep 1
done

if [ -p /tmp/bacula-fifo ] ; then
  # Change the permissions for the fifo here - assumes you've set this up in 
/etc/sudo.
  # If you've added the bacula group to the db2inst1 user you may not need this.
  sudo chmod o+rw /tmp/bacula-fifo

  # Restore the database here
  db2 restore .... without prompting
fi

CUT-------

Best Regards,

Brett Delle Grazie
Senior Developer
TBC Ltd.
Technology House, 45 Laud Street, Croydon, Surrey, CR0 1SX
Switchboard: +44 (0)20 8680 8080 Fax: +44 (0)20 8688 8645
Direct Dial: +44 (0)20 8633 8406
e-mail: [EMAIL PROTECTED]
web: <http://www.tbc.co.uk/>
Complex Problems Require Intelligent Thinking
_____________________________________________________________________________________
Although every effort has been made to ensure the accuracy of the information 
supplied, the information
contained within this e-mail has not been submitted to any formal testing by 
TBC and is supplied AS IS.
The use of this information, the implementation of the techniques supplied 
within, the interpretation of how
this information affects the environment and the execution of any steps deemed 
necessary before
using this information is the responsibility of the customer. TBC will not be 
held responsible or liable
for any consequential loss or damage caused as a result of following these 
procedures. If you have any
doubts then please contact TBC immediately


-----Original Message-----
From: Thomas E. Ruth [mailto:[EMAIL PROTECTED]
Sent: 12 August 2005 19:33
To: Brett Delle Grazie
Cc: bacula-users@lists.sourceforge.net
Subject: Re: [Bacula-users] Backup / Restore of DB2 Databases using
Fifo's


I havn't been able to automate a restore completely within bacula for
DB2 databases, but I've gotten close.  The bacula restore process
creates a FIFO with only root permissions but doesn't change the
permissions of the actual fifo file until data starts restoring to it.
At that time though, it's too late for the DB2 process (I think the file 
is actually deleted and re-created and the DB2 process loses it's handle 
on it).

I've attached the script that I use, maybe it will help you. I've also
attached a patch to fd_cmds.c in the director source directory that will 
allow this script to work properly (otherwise, my script can't tell if
the backup is incremental, or full, and doesn't know what to do in
either case).

Here is my job resource I use with these scripts:

Job {
  Name = database-db2
  JobDefs = "WeeklyFull"
  Client = "tiamat2-fd"
  File Set = "Database DB2"
  Client Run Before Job = "su - <instance owner> -c \"/<database
directory>/backupdb.sh '%t' '%l
' '<instance owner>' '<database name>'\""
  Client Run After Job = "su - <instance owner> -c \"/<database
directory>/prunelogs.sh '%t' '%l
' '<instance owner>' '<database name>'\""
  Write Bootstrap = "/var/lib/bacula/database.bst"
}

Job {
  Name = restore-database-db2
  Type = Restore
  Client = tiamat2-fd
  File Set = "Database DB2"
  Messages = Standard
  Storage = Tape
  Pool = Default
  Client Run Before Job = "su - <instance owner> -c \"<database
dir>/backupdb.sh '%t' '%l
' '<instance owner>' '<database name>'\""
  Client Run After Job = "su - <instance owner> -c \"<database
dir>/prunelogs.sh '%t' '%l
' '<instance owner>' '<database name>'\""
  Where = "/"
}

FileSet {
  Name = "Database DB2"
  Include {
    Options { signature=MD5; readfifo=Yes }
    File = "<database dir>/dbpipe"
  }
  Include {
    Options { signature=MD5 }
    File = "<database dir>/<instance name>/NODE0000/SQL00001"
    File = "<database dir>/<instance name>/NODE0000/sqldbdir"
    File = "<database dir>/backupdb.sh"
    File = "<database dir>/prunelogs.sh"
  }
}

You will need to create a new set of these job/file resources for each
database instance you have.

If you improve these scripts at all to make a restore of a DB2 database
a bit more automated, please let me know!

Tom

[EMAIL PROTECTED] wrote:

> Hi,
>
> I'm using bacula to backup a DB2 database to a fifo.
>
> The backup is working correctly thanks to the additions made to the
> developer's documentation.
>
> The problem I have at the moment is getting the restore process to work.
>
> The idea was to create the fifo (using mkfifo) in the same location as 
> previously used then start the Db2
> restore process using the usual DB2 restore db ...xxxx... commands in
> the 'run client before job' option but redirecting
> standard input to null and standard output and standard error to a log 
> file (as per the developer documentation)
>
> While this part works, when the backed up fifo is restored it is
> forced into having the attributes:
> /tmp/bacula-fifo (root, bacula) prw-r-----
> This means that DB2 no longer has access to the fifo and responds with 
> a 'Attempt to access media /tmp/bacula-fifo is denied' error.
>
> Despite the fact the fifo is created with the following attributes
> when it was backed up originally (and prior to the restore process):
> /tmp/bacula-fifo (db2inst1,db2grp1) prw-rw-rw
>
> I'm using 1.36.3 (RHEL2.1AS and RHEL3AS)
>
> Does anyone have any ideas?
>
> Thanks,
>
> Best Regards,
>
> Brett
>




-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Bacula-users mailing list
Bacula-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/bacula-users

Reply via email to