From 2499795e233e43bd4eb4d99e0473b67e6c6b60d8 Mon Sep 17 00:00:00 2001 From: Marco van Wieringen Date: Fri, 14 May 2010 10:16:26 +0200 Subject: [PATCH] First stab at a simple script to dump the content of the complete Ingres bacula database for disaster recovery purposes. --- bacula/src/cats/make_ingres_catalog_backup.in | 67 +++++++++++++++++++ .../src/cats/restore_ingres_catalog_backup.in | 52 ++++++++++++++ 2 files changed, 119 insertions(+) create mode 100755 bacula/src/cats/make_ingres_catalog_backup.in create mode 100755 bacula/src/cats/restore_ingres_catalog_backup.in diff --git a/bacula/src/cats/make_ingres_catalog_backup.in b/bacula/src/cats/make_ingres_catalog_backup.in new file mode 100755 index 0000000000..6bf784dca2 --- /dev/null +++ b/bacula/src/cats/make_ingres_catalog_backup.in @@ -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 index 0000000000..a12e101fd3 --- /dev/null +++ b/bacula/src/cats/restore_ingres_catalog_backup.in @@ -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 -- 2.39.5