]> git.sur5r.net Git - bacula/bacula/blobdiff - bacula/src/cats/make_catalog_backup.in
Add %D option to edit_job_code, simplify callbacks on director side
[bacula/bacula] / bacula / src / cats / make_catalog_backup.in
index 98b1ae33876361dbb42a35c67379ee4fffef5d05..58ed650861342b280e352582ee8ea358d65bb520 100755 (executable)
 #     password.
 #  $4 is the host on which the database is located
 #     (default "")
+#  $5 is the type of database
 #
 #
-BINDIR=@SQL_BINDIR@
+
+default_db_type=@DEFAULT_DB_TYPE@
+
+#
+# See if the fifth argument is a valid backend name.
+# If so the user overrides the default database backend.
+#
+if [ $# -ge 5 ]; then
+   case $5 in
+     sqlite3)
+       db_type=$5
+       ;;
+     mysql)
+       db_type=$5
+       ;;
+     postgresql)
+       db_type=$5
+       ;;
+     ingres)
+       db_type=$5
+       ;;
+     *)
+       ;;
+   esac
+fi
+
+#
+# If no new db_type is gives use the default db_type.
+#
+if [ -z "${db_type}" ]; then
+   db_type="${default_db_type}"
+fi
 
 cd @working_dir@
 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_TYPE@ ; then
+
+case ${db_type} in
+  sqlite3)
+    BINDIR=@SQLITE_BINDIR@
+    echo ".dump" | ${BINDIR}/sqlite3 $1.db >$1.sql
+    ;;
+  mysql)
+    BINDIR=@MYSQL_BINDIR@
     if test $# -gt 2; then
       MYSQLPASSWORD=" --password=$3"
     else
@@ -36,23 +72,22 @@ 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
+    ;;
+  postgresql)
+    BINDIR=@POSTGRESQL_BINDIR@
+    if test $# -gt 2; then
+      PGPASSWORD=$3
+      export PGPASSWORD
+    fi
+    if test $# -gt 3; then
+      PGHOST=" --host=$4"
     else
-      echo ".dump" | ${BINDIR}/sqlite3 $1.db >$1.sql
+      PGHOST=""
     fi
-  fi
-fi
+    # you could also add --compress for compression.  See man pg_dump
+    exec ${BINDIR}/pg_dump -c $PGHOST -U $2 $1 >$1.sql
+    ;;
+esac
 #
 #  To read back a MySQL database use: 
 #     cd @working_dir@
@@ -67,6 +102,6 @@ fi
 #  To read back a PostgreSQL database use:
 #     cd @working_dir@
 #     dropdb bacula
-#     createdb bacula
+#     createdb bacula -T template0 -E SQL_ASCII
 #     psql bacula <bacula.sql
 #