File: save_db_schema

package info (click to toggle)
postgresql 6.5.3-27
  • links: PTS
  • area: main
  • in suites: potato
  • size: 28,360 kB
  • ctags: 20,905
  • sloc: ansic: 204,608; yacc: 10,718; sql: 9,387; sh: 9,379; java: 8,835; tcl: 7,709; makefile: 3,376; lex: 1,642; perl: 1,034; python: 959; cpp: 847; asm: 70; pascal: 42; awk: 10; sed: 8
file content (51 lines) | stat: -rw-r--r-- 1,400 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#! /bin/sh
# This script is run only during upgrade of a postgresql Debian package.
# It is not intended for normal use.

if [ -f /etc/postgresql/postgresql.env ]
then
	. /etc/postgresql/postgresql.env
else
	echo $0: cannot find /etc/postgresql/postgresql.env
	exit 1
fi

PGPORT=5341
export PGPORT

if [ ! -f $PGDATA/PG_VERSION ]
then
	echo $0: Cannot find database; unable to dump a database structure for
	echo potential upgrades.
	exit 2
else
	PG_VERSION=`cat $PGDATA/PG_VERSION`
fi

PATH=/bin:/usr/bin:/usr/lib/postgresql/bin:/usr/lib/postgresql/dumpall/$PG_VERSION
LD_LIBRARY_PATH=/usr/lib:/usr/lib/postgresql/dumpall/$PG_VERSION
export PATH LD_LIBRARY_PATH

cd /usr/lib/postgresql/dumpall
rm -f db.out.$$                     # just in case...
if pg_dumpall -s > db.out.$$
then
	cat $PGDATA/PG_VERSION > db.out.version
	rm -f db.out
	# "upgrade" MUST be the 3rd word in the first line of db.out
	echo "-- prerm upgrade on `date` from version `cat $PGDATA/PG_VERSION`" >db.out
	cat db.out.$$ >>db.out
	echo "-- prerm upgrade completed on `date`" >>db.out
	rm -f db.out.$$
	chmod 440 db.out

	# record the default encoding for initdb
	DEFAULT_ENCODING=`psql -qt -c "select encoding from pg_database where datname = 'template1'"`
	/usr/lib/postgresql/bin/pg_encoding $DEFAULT_ENCODING >default_encoding
else
	rm -f db.out.$$
	echo $0: pg_dumpall of database structure has failed
	exit 3
fi

exit 0