Project

General

Profile

1
#!/bin/sh
2
# Dumps a schema of the vegbien db
3

    
4
selfDir="$(dirname -- "$0")"
5

    
6
if ! test "$#" -ge 1; then
7
    echo "Usage: env [schema=1] [data=1] [plain=1] [owners=1] [dump_opts=...] \
8
$0 {<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=plain
19
    else set -- "$@" --format=custom --compress=9
20
    fi
21
    owners=1
22
else
23
    set -- "$@" --inserts
24
    test -n "$schema" && set -- "$@" --schema-only
25
fi
26
test -n "$owners" || set -- "$@" --no-owner
27
set -- "$@" $dump_opts
28

    
29
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
(53-53/86)