summaryrefslogtreecommitdiffstats
path: root/main/postgresql/pg-restore.initd
diff options
context:
space:
mode:
Diffstat (limited to 'main/postgresql/pg-restore.initd')
-rw-r--r--main/postgresql/pg-restore.initd20
1 files changed, 13 insertions, 7 deletions
diff --git a/main/postgresql/pg-restore.initd b/main/postgresql/pg-restore.initd
index aaf07cbe7..91c69d18f 100644
--- a/main/postgresql/pg-restore.initd
+++ b/main/postgresql/pg-restore.initd
@@ -1,5 +1,7 @@
#!/sbin/runscript
+. /etc/conf.d/postgresql
+
opts="${opts} dump restore"
depend() {
@@ -7,18 +9,22 @@ depend() {
}
restore() {
- [ -z "$PGDUMP" ] && return 0
+ yesno "$PGDUMP" && return 0
ebegin "Restoring PostgreSQL $PGDUMP"
- psql -U ${PG_USER:-postgres} ${PSQL_OPTS} -f "$PGDUMP"
- eend $?
- if [ -z "$KEEP_DUMP" ]; then
- rm -f "$PGDUMP"
- fi
+ 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() {
- [ -z "$PGDUMP" ] && return 0
+ 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() {