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