Project

General

Profile

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