aboutsummaryrefslogtreecommitdiffstats
path: root/main/postgresql/pg-restore.initd
diff options
context:
space:
mode:
authorNathan Angelacos <nangel@nothome.org>2010-05-17 18:35:05 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2010-05-17 18:40:19 +0000
commit80f783a77b2e862c4aa30edb5493cf8be30cbea6 (patch)
tree8edddf7da307969ef931ed0e069d8dd51a62f0c7 /main/postgresql/pg-restore.initd
parentab572325f457d4e85d086c13833726dde9bd4ded (diff)
downloadaports-80f783a77b2e862c4aa30edb5493cf8be30cbea6.tar.bz2
aports-80f783a77b2e862c4aa30edb5493cf8be30cbea6.tar.xz
main/postgresql: enhancements to the database restore on reboot
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 aaf07cbe7d..91c69d18f4 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() {