1
|
#!/bin/sh
|
2
|
# Dumps a schema of the vegbien db
|
3
|
|
4
|
selfDir="$(dirname -- "$0")"
|
5
|
|
6
|
if ! test "$#" -eq 1; then
|
7
|
echo "Usage: env [schema=1] [data=1] [plain=1] [owners=1] [opts=...] $0 \
|
8
|
{<schema>|all} [opts...] >out"|fold -s >&2
|
9
|
exit 2
|
10
|
fi
|
11
|
: "${schema=1}"
|
12
|
|
13
|
schema_="$1"
|
14
|
shift
|
15
|
test "$schema_" != all && set -- --schema="\"$schema_\"" "$@"
|
16
|
|
17
|
if test -n "$data"; then
|
18
|
if test -n "$plain"; then set -- "$@" --format=p
|
19
|
else set -- "$@" --format=c --compress=9
|
20
|
fi
|
21
|
owners=1
|
22
|
elif test -n "$schema"; then set -- "$@" --schema-only
|
23
|
fi
|
24
|
test -n "$owners" || set -- "$@" --no-owner --no-privileges
|
25
|
set -- "$@" $opts
|
26
|
|
27
|
pg_dump ()
|
28
|
{
|
29
|
set -x
|
30
|
exec "$selfDir/postgres_vegbien" pg_dump "$@"
|
31
|
}
|
32
|
if test -n "$data"; then pg_dump "$@"
|
33
|
else pg_dump "$@"|grep -vF 'SELECT pg_catalog.setval'
|
34
|
fi
|