Project

General

Profile

1 2092 aaronmk
#!/bin/sh
2
# Dumps a schema of the vegbien db
3
4
selfDir="$(dirname -- "$0")"
5
6
if ! test "$#" -eq 1; then
7 3400 aaronmk
    echo "Usage: env [data=1] [plain=1] [owners=1] $0 [schema] [opts...] >out"
8 2092 aaronmk
    exit 2
9
fi
10 3397 aaronmk
11 3400 aaronmk
if test "${1#-}" = "$1"; then # $1 does not start with "-"
12
    schemaOpt=--schema="\"$1\""
13
    shift
14
    set -- "$schemaOpt" "$@"
15
fi
16
17 3388 aaronmk
if test -n "$data"; then
18
    if test -n "$plain"; then dataOpts=--format=p
19
    else dataOpts='--format=c --compress=9'
20
    fi
21 3397 aaronmk
    owners=1
22 3388 aaronmk
else dataOpts=--schema-only
23
fi
24
test -n "$owners" && ownerOpts= || ownerOpts='--no-owner --no-privileges'
25 2092 aaronmk
26 3400 aaronmk
(set -x; "$selfDir/../bin/postgres_vegbien" pg_dump "$@" \
27 3396 aaronmk
$dataOpts $ownerOpts --use-set-session-authorization)