]> git.sur5r.net Git - bacula/bacula/commitdiff
First stab at a simple script to dump the content of the complete Ingres bacula datab...
authorMarco van Wieringen <mvw@planets.elm.net>
Fri, 14 May 2010 08:16:26 +0000 (10:16 +0200)
committerEric Bollengier <eric@eb.homelinux.org>
Mon, 2 Aug 2010 14:53:48 +0000 (16:53 +0200)
bacula/src/cats/make_ingres_catalog_backup.in [new file with mode: 0755]
bacula/src/cats/restore_ingres_catalog_backup.in [new file with mode: 0755]

diff --git a/bacula/src/cats/make_ingres_catalog_backup.in b/bacula/src/cats/make_ingres_catalog_backup.in
new file mode 100755 (executable)
index 0000000..6bf784d
--- /dev/null
@@ -0,0 +1,67 @@
+#!/bin/sh
+#
+# shell script to make a dump of the bacula Ingres database using copydb and make
+# a base64 encoded tar of the content.
+#
+
+bindir=@SQL_BINDIR@
+PATH="$bindir:$PATH"
+db_name=${db_name:-@db_name@}
+db_user=${db_user:-@db_user@}
+working_dir="@working_dir@"
+
+#
+# Source the Ingres settings when they exist.
+#
+[ -f ${bindir}/../../.ingIIsh  ] && . ${bindir}/../../.ingIIsh 
+
+#
+# See if the dumpdir exists.
+#
+[ ! -d ${working_dir}/ingres_dump ] && mkdir -p ${working_dir}/ingres_dump
+
+#
+# Generate the copy.in and copy.out file
+#
+copydb \
+${db_name} \
+-u${db_user} \
+-dest=${working_dir}/ingres_dump \
+-d ${working_dir}/ingres_dump \
+> /dev/null 2>&1
+
+#
+# If copydb created a copy.out file run it.
+#
+if [ -f ${working_dir}/ingres_dump/copy.out ]; then
+   #
+   # Run the sql to create the dumps of the tables.
+   #
+   sql \
+   -u${db_user} \
+   ${db_name} \
+   < ${working_dir}/ingres_dump/copy.out \
+   > /dev/null 2>&1 && rm ${working_dir}/ingres_dump/copy.out
+
+   #
+   # Tar up the dump and uuencode it.
+   #
+   cd ${working_dir}/ingres_dump || exit 1
+   case `uname -s` in
+      Linux)
+         tar cf - . | gzip -c | base64 
+         ;;
+      SunOS)
+         tar cf - . | gzip -c | uuencode -m -
+         ;;
+      *)
+         echo "Unsupported OS type encountered, `uname -s`"
+         exit 1
+         ;;
+   esac
+   cd /
+
+   rm -rf ${working_dir}/ingres_dump
+fi
+
+exit 0
diff --git a/bacula/src/cats/restore_ingres_catalog_backup.in b/bacula/src/cats/restore_ingres_catalog_backup.in
new file mode 100755 (executable)
index 0000000..a12e101
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/sh
+#
+# shell script to restore a dump of the bacula Ingres database using
+# a base64 encoded tar of the content.
+#
+
+bindir=@SQL_BINDIR@
+PATH="$bindir:$PATH"
+db_name=${db_name:-@db_name@}
+db_user=${db_user:-@db_user@}
+working_dir="@working_dir@"
+
+#
+# Source the Ingres settings when they exist.
+#
+[ -f ${bindir}/../../.ingIIsh  ] && . ${bindir}/../../.ingIIsh
+
+#
+# See if the dumpdir exists.
+#
+[ ! -d ${working_dir}/ingres_dump ] && mkdir -p ${working_dir}/ingres_dump
+
+#
+# Decode the tar and restore it.
+#
+cd ${working_dir}/ingres_dump || exit 1
+case `uname -s` in
+   Linux)
+      base64 -d | gzip -dc | tar xf -
+      ;;
+   SunOS)
+      uudecode -p | gzip -dc | tar xf -
+      ;;
+   *)
+      echo "Unsupported OS type encountered, `uname -s`"
+      exit 1
+      ;;
+esac
+
+if [ $? = 0 ]; then
+   #
+   # Restore the data
+   #
+   sql -u${db_user} ${db_name} < copy.in
+   sysmod ${db_name}
+fi
+
+cd /
+
+rm -rf ${working_dir}/ingres_dump
+
+exit 0