File: save_db_schema

package info (click to toggle)
postgresql 7.2.1-2woody8
  • links: PTS
  • area: main
  • in suites: woody
  • size: 42,424 kB
  • ctags: 30,027
  • sloc: ansic: 290,568; java: 18,529; sh: 12,197; sql: 11,401; yacc: 11,189; tcl: 8,063; perl: 4,067; makefile: 3,332; xml: 2,874; lex: 2,799; python: 1,237; cpp: 845; pascal: 81; asm: 70; awk: 20; sed: 8
file content (49 lines) | stat: -rw-r--r-- 1,310 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
#! /bin/bash
# This script is run only during upgrade of a postgresql Debian package.
# It is not intended for normal use.
# [At release 7.1, it is not used at all, because pg_upgrade no longer
# works; it is retained against the time that pg_upgrade works again.]

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

PATH=/bin:/usr/bin:/usr/lib/postgresql/bin
export PATH

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

cd /usr/lib/postgresql/dumpall
rm -f db.out.$$                     # just in case...
if pg_dumpall > db.out.$$
then
	cat $PGDATA/PG_VERSION > db.out.version
	rm -f db.out
	echo "-- prerm full on `date` from version `cat $PGDATA/PG_VERSION`" >db.out
	cat db.out.$$ >>db.out
	echo "-- prerm full 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