]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/make_catalog_backup.in
kes Cancel storage daemon in all cases where FD reports error. This
[bacula/bacula] / bacula / src / cats / make_catalog_backup.in
1 #!/bin/sh
2 #
3 # This script dumps your Bacula catalog in ASCII format
4 # It works for MySQL, SQLite, and PostgreSQL
5 #
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
9 #     (default = bacula).
10 #  $3 is the password with which to access the database or "" if no password
11 #     (default "")
12 #  $4 is the host on which the database is located
13 #     (default "")
14 #
15 #
16 BINDIR=@SQL_BINDIR@
17
18 cd @working_dir@
19 rm -f $1.sql
20 if test xsqlite = x@DB_TYPE@ ; then
21   echo ".dump" | ${BINDIR}/sqlite $1.db >$1.sql
22 else
23   if test xmysql = x@DB_TYPE@ ; then
24     if test $# -gt 2; then
25       MYSQLPASSWORD=" --password=$3"
26     else
27       MYSQLPASSWORD=""
28     fi
29     if test $# -gt 3; then
30       MYSQLHOST=" --host=$4"
31     else
32       MYSQLHOST=""
33     fi
34     ${BINDIR}/mysqldump -u $2$MYSQLPASSWORD$MYSQLHOST -f --opt $1 >$1.sql
35   else                        
36     if test xpostgresql = x@DB_TYPE@ ; then
37       if test $# -gt 2; then
38         PGPASSWORD=$3
39         export PGPASSWORD
40       fi
41       if test $# -gt 3; then
42         PGHOST=" --host=$4"
43       else
44         PGHOST=""
45       fi
46       exec ${BINDIR}/pg_dump -c $PGHOST -U $2 $1 >$1.sql
47     else
48       echo ".dump" | ${BINDIR}/sqlite3 $1.db >$1.sql
49     fi
50   fi
51 fi
52 #
53 #  To read back a MySQL database use: 
54 #     cd @working_dir@
55 #     rm -f ${BINDIR}/../var/bacula/*
56 #     mysql <bacula.sql
57 #
58 #  To read back a SQLite database use:
59 #     cd @working_dir@
60 #     rm -f bacula.db
61 #     sqlite bacula.db <bacula.sql
62 #
63 #  To read back a PostgreSQL database use:
64 #     cd @working_dir@
65 #     dropdb bacula
66 #     createdb bacula
67 #     psql bacula <bacula.sql
68 #