X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fcats%2Fmake_catalog_backup.in;h=18c28216083324d340729d3ffa6e6cd79170c1d4;hb=0d68db46b120f0c8178fe4bffbb842d346f3b0a2;hp=dbc4d5943571f41a4e90a869512e348f31ae0a48;hpb=1e5844fb1251d4398a388a0bb507b8ca7504a649;p=bacula%2Fbacula diff --git a/bacula/src/cats/make_catalog_backup.in b/bacula/src/cats/make_catalog_backup.in index dbc4d59435..18c2821608 100755 --- a/bacula/src/cats/make_catalog_backup.in +++ b/bacula/src/cats/make_catalog_backup.in @@ -1,23 +1,58 @@ #!/bin/sh # # This script dumps your Bacula catalog in ASCII format -# It works for either MySQL or SQLite +# 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). +# $3 is the password with which to access the database or "" if no password +# (default "") +# $4 is the host on which the database is located +# (default "") +# +# +BINDIR=@SQL_BINDIR@ + cd @working_dir@ -rm -f bacula.sql -if test xsqlite = x@DB_NAME@ ; then - echo ".dump" | @SQL_BINDIR@/sqlite bacula.db >bacula.sql +rm -f $1.sql +if test xsqlite = x@DB_TYPE@ ; then + echo ".dump" | ${BINDIR}/sqlite $1.db >$1.sql else - if test xmysql = x@DB_NAME@ ; then - @SQL_BINDIR@/mysqldump -u bacula -f --opt bacula >bacula.sql - else - @SQL_BINDIR@/pg_dump -U bacula bacula >bacula.sql + if test xmysql = x@DB_TYPE@ ; then + if test $# -gt 2; then + MYSQLPASSWORD=" --password=$3" + else + MYSQLPASSWORD="" + fi + if test $# -gt 3; then + MYSQLHOST=" --host=$4" + else + MYSQLHOST="" + fi + ${BINDIR}/mysqldump -u $2$MYSQLPASSWORD$MYSQLHOST -f --opt $1 >$1.sql + else + if test xpostgresql = x@DB_TYPE@ ; then + if test $# -gt 2; then + PGPASSWORD=$3 + export PGPASSWORD + fi + if test $# -gt 3; then + PGHOST=" --host=$4" + else + PGHOST="" + fi + exec ${BINDIR}/pg_dump -c $PGHOST -U $2 $1 >$1.sql + else + echo ".dump" | ${BINDIR}/sqlite3 $1.db >$1.sql + fi fi fi # # To read back a MySQL database use: # cd @working_dir@ -# rm -f @SQL_BINDIR@/../var/bacula/* +# rm -f ${BINDIR}/../var/bacula/* # mysql