]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/make_catalog_backup.in
ebl fix escape bug
[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 #
13 #
14 BINDIR=@SQL_BINDIR@
15
16 cd @working_dir@
17 rm -f $1.sql
18 if test xsqlite = x@DB_TYPE@ ; then
19   echo ".dump" | ${BINDIR}/sqlite $1.db >$1.sql
20 else
21   if test xmysql = x@DB_TYPE@ ; then
22     if test $# -gt 2; then
23       MYSQLPASSWORD=" --password=$3"
24     else
25       MYSQLPASSWORD=""
26     fi
27     ${BINDIR}/mysqldump -u $2$MYSQLPASSWORD -f --opt $1 >$1.sql
28   else                        
29     if test xpostgresql = x@DB_TYPE@ ; then
30       if test $# -gt 2; then
31         PGPASSWORD=$3
32         export PGPASSWORD
33       fi
34       exec ${BINDIR}/pg_dump -c -U $2 $1 >$1.sql
35     else
36       echo ".dump" | ${BINDIR}/sqlite3 $1.db >$1.sql
37     fi
38   fi
39 fi
40 #
41 #  To read back a MySQL database use: 
42 #     cd @working_dir@
43 #     rm -f ${BINDIR}/../var/bacula/*
44 #     mysql <bacula.sql
45 #
46 #  To read back a SQLite database use:
47 #     cd @working_dir@
48 #     rm -f bacula.db
49 #     sqlite bacula.db <bacula.sql
50 #
51 #  To read back a PostgreSQL database use:
52 #     cd @working_dir@
53 #     dropdb bacula
54 #     createdb bacula
55 #     psql bacula <bacula.sql
56 #