]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/cats/create_postgresql_database.in
Tweak create_postgresql_database.in
[bacula/bacula] / bacula / src / cats / create_postgresql_database.in
1 #!/bin/sh
2 #
3 # shell script to create Bacula database(s)
4 #
5
6 bindir=@SQL_BINDIR@
7 db_name=@db_name@
8
9 #
10 # use SQL_ASCII to be able to put any filename into
11 #  the database even those created with unusual character sets
12 ENCODING="ENCODING 'SQL_ASCII'"
13  
14 #
15 # Please note: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
16 #  We do not recommend that you use ENCODING 'SQL_UTF8'
17 #  It can result in creating filenames in the database that
18 #  cannot be seen or restored.
19 # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
20 #
21 #
22 if $bindir/psql -f - -d template1 $* <<END-OF-DATA
23 \set ON_ERROR_STOP on
24 CREATE DATABASE ${db_name} $ENCODING TEMPLATE template0;
25 ALTER DATABASE ${db_name} SET datestyle TO 'ISO, YMD';
26 END-OF-DATA
27 then
28    echo "Creation of ${db_name} database succeeded."
29 else
30    echo " "
31    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
32    echo "!!!! Creation of ${db_name} database failed. !!!!"
33    echo "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
34 fi
35 if $bindir/psql -l ${dbname} | grep " ${db_name}.*SQL_ASCII" >/dev/null; then 
36    echo "Database encoding OK"
37 else
38    echo " "
39    echo "Database encoding bad. Do not use this database"
40    echo " "
41 fi