]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/make_ingres_catalog_backup.in
Fix sql typo
[bacula/bacula] / bacula / src / cats / make_ingres_catalog_backup.in
1 #!/bin/sh
2 #
3 # shell script to make a dump of the bacula Ingres database using copydb and make
4 # a base64 encoded tar of the content.
5 #
6
7 bindir=@SQL_BINDIR@
8 PATH="$bindir:$PATH"
9 db_name=${db_name:-@db_name@}
10 db_user=${db_user:-@db_user@}
11 working_dir="@working_dir@"
12
13 #
14 # Source the Ingres settings when they exist.
15 #
16 [ -f ${bindir}/../../.ingIIsh  ] && . ${bindir}/../../.ingIIsh 
17
18 #
19 # See if the dumpdir exists.
20 #
21 [ ! -d ${working_dir}/ingres_dump ] && mkdir -p ${working_dir}/ingres_dump
22
23 #
24 # Generate the copy.in and copy.out file
25 #
26 copydb \
27 ${db_name} \
28 -u${db_user} \
29 -dest=${working_dir}/ingres_dump \
30 -d ${working_dir}/ingres_dump \
31 > /dev/null 2>&1
32
33 #
34 # If copydb created a copy.out file run it.
35 #
36 if [ -f ${working_dir}/ingres_dump/copy.out ]; then
37    #
38    # Run the sql to create the dumps of the tables.
39    #
40    sql \
41    -u${db_user} \
42    ${db_name} \
43    < ${working_dir}/ingres_dump/copy.out \
44    > /dev/null 2>&1 && rm ${working_dir}/ingres_dump/copy.out
45
46    #
47    # Tar up the dump and uuencode it.
48    #
49    cd ${working_dir}/ingres_dump || exit 1
50    case `uname -s` in
51       Linux)
52          tar cf - . | gzip -c | base64 
53          ;;
54       SunOS)
55          tar cf - . | gzip -c | uuencode -m -
56          ;;
57       *)
58          echo "Unsupported OS type encountered, `uname -s`"
59          exit 1
60          ;;
61    esac
62    cd /
63
64    rm -rf ${working_dir}/ingres_dump
65 fi
66
67 exit 0