X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=bacula%2Fsrc%2Fcats%2Fmake_catalog_backup.in;h=b27ffb77d94fe78baff684b0b24a953295638ad9;hb=2c468fb0b85ed227763f925727c31faa865f5012;hp=6c20a8ebd6287848583509c69225025c6ab4e2fc;hpb=25774d88025d0b1ae411421bb536929cbcc70a80;p=bacula%2Fbacula diff --git a/bacula/src/cats/make_catalog_backup.in b/bacula/src/cats/make_catalog_backup.in index 6c20a8ebd6..b27ffb77d9 100755 --- a/bacula/src/cats/make_catalog_backup.in +++ b/bacula/src/cats/make_catalog_backup.in @@ -8,37 +8,56 @@ # $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 ""). WARNING!!! Passing the password via the command line is +# insecure and should not be used since any user can display the command +# line arguments and the environment using ps. Please consult your +# MySQL or PostgreSQL manual for secure methods of specifying the +# password. +# $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 $1.db >$1.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 + if test xmysql = x@DB_TYPE@ ; then if test $# -gt 2; then MYSQLPASSWORD=" --password=$3" else MYSQLPASSWORD="" fi - @SQL_BINDIR@/mysqldump -u $2$MYSQLPASSWORD -f --opt $1 >$1.sql + 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_NAME@ ; then + if test xpostgresql = x@DB_TYPE@ ; then if test $# -gt 2; then - PGPASSWORD=$3 - export PGPASSWORD + PGPASSWORD=$3 + export PGPASSWORD + fi + if test $# -gt 3; then + PGHOST=" --host=$4" + else + PGHOST="" fi - exec @SQL_BINDIR@/pg_dump -U $2 $1 >$1.sql + # you could also add --compress for compression. See man pg_dump + exec ${BINDIR}/pg_dump -c $PGHOST -U $2 $1 >$1.sql else - echo ".dump" | @SQL_BINDIR@/sqlite3 $1.db >$1.sql + 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