#!/bin/sh
#
# This script dumps your Bacula catalog in ASCII format
# It works for MySQL, SQLite, and PostgreSQL
#
#  $1 is the name of the database to be backed up and the name
#     of the output file (default = bacula).
#  $2 is the user name with which to access the database
#     (default = bacula).
#
#
cd /var/lib/bacula
rm -f bacula.sql
if test xsqlite = xmysql ; then
  echo ".dump" | /usr/bin/sqlite $1.db >$1.sql
else
  if test xmysql = xmysql ; then
    /usr/bin/mysqldump -u $2 -f --opt $1 >$1.sql
  else
    /usr/bin/pg_dump -U $2 $1 >$1.sql
  fi
fi
#
#  To read back a MySQL database use: 
#     cd /var/lib/bacula
#     rm -f /usr/bin/../var/bacula/*
#     mysql <bacula.sql
#
#  To read back a SQLite database use:
#     cd /var/lib/bacula
#     rm -f bacula.db
#     sqlite bacula.db <bacula.sql
#
#  To read back a PostgreSQL database use:
#     cd /var/lib/bacula
#     dropdb bacula
#     psql bacula <bacula.sql
#
