3 # This script dumps your Bacula catalog in ASCII format
4 # It works for MySQL, SQLite, and PostgreSQL
6 # $1 is the name of the database to be backed up and the name
7 # of the output file (default = bacula).
8 # $2 is the user name with which to access the database
10 # $3 is the password with which to access the database or "" if no password
11 # (default ""). WARNING!!! Passing the password via the command line is
12 # insecure and should not be used since any user can display the command
13 # line arguments and the environment using ps. Please consult your
14 # MySQL or PostgreSQL manual for secure methods of specifying the
16 # $4 is the host on which the database is located
18 # $5 is the type of database
22 default_db_type=@DEFAULT_DB_TYPE@
25 # See if the fifth argument is a valid backend name.
26 # If so the user overrides the default database backend.
48 # If no new db_type is gives use the default db_type.
50 if [ -z "${db_type}" ]; then
51 db_type="${default_db_type}"
59 BINDIR=@SQLITE_BINDIR@
60 echo ".dump" | ${BINDIR}/sqlite3 $1.db >$1.sql
64 if test $# -gt 2; then
65 MYSQLPASSWORD=" --password=$3"
69 if test $# -gt 3; then
70 MYSQLHOST=" --host=$4"
74 ${BINDIR}/mysqldump -u ${2}${MYSQLPASSWORD}${MYSQLHOST} -f --opt $1 >$1.sql
77 BINDIR=@POSTGRESQL_BINDIR@
78 if test $# -gt 2; then
82 if test $# -gt 3; then
87 # you could also add --compress for compression. See man pg_dump
88 exec ${BINDIR}/pg_dump -c $PGHOST -U $2 $1 >$1.sql
92 # To read back a MySQL database use:
94 # rm -f ${BINDIR}/../var/bacula/*
97 # To read back a SQLite database use:
100 # sqlite bacula.db <bacula.sql
102 # To read back a PostgreSQL database use:
105 # createdb bacula -T template0 -E SQL_ASCII
106 # psql bacula <bacula.sql