mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2026-01-13 04:32:09 +01:00
38 lines
661 B
Plaintext
38 lines
661 B
Plaintext
#!/sbin/runscript
|
|
|
|
. /etc/conf.d/postgresql
|
|
|
|
opts="${opts} dump restore"
|
|
|
|
depend() {
|
|
need postgresql
|
|
}
|
|
|
|
restore() {
|
|
yesno "$PGDUMP" && return 0
|
|
ebegin "Restoring PostgreSQL $PGDUMP"
|
|
psql -U ${PG_USER:-postgres} ${PSQL_OPTS} -f "$PGDUMP" >/dev/null 2>/dev/null
|
|
yesno "$KEEP_DUMP" || rm -f "$PGDUMP"
|
|
|
|
su -l ${PGUSER} \
|
|
-c "env PGDATA=\"${PGDATA}\" /usr/bin/pg_ctl reload " >/dev/null
|
|
eend $res
|
|
}
|
|
|
|
dump() {
|
|
yesno "$PGDUMP" && return 0
|
|
mkdir -p "$( dirname "$PGDUMP" )"
|
|
ebegin "Saving PostgreSQL databases to $PGDUMP"
|
|
pg_dumpall -U ${PG_USER:-postgres} ${PG_DUMPALL_OPTS} -f "$PGDUMP"
|
|
eend $?
|
|
}
|
|
|
|
start() {
|
|
restore
|
|
}
|
|
|
|
stop() {
|
|
dump
|
|
}
|
|
|