Project

General

Profile

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
else
23
    set -- "$@" --inserts
24
    test -n "$schema" && set -- "$@" --schema-only
25
fi
26
test -n "$owners" || set -- "$@" --no-owner --no-privileges
27
set -- "$@" $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
(38-38/62)