aboutsummaryrefslogtreecommitdiffstats
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.initd31
1 files changed, 31 insertions, 0 deletions
diff --git a/main/postgresql/pg-restore.initd b/main/postgresql/pg-restore.initd
new file mode 100644
index 0000000000..aaf07cbe7d
--- /dev/null
+++ b/main/postgresql/pg-restore.initd
@@ -0,0 +1,31 @@
+#!/sbin/runscript
+
+opts="${opts} dump restore"
+
+depend() {
+ need postgresql
+}
+
+restore() {
+ [ -z "$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
+}
+
+dump() {
+ [ -z "$PGDUMP" ] && return 0
+ pg_dumpall -U ${PG_USER:-postgres} ${PG_DUMPALL_OPTS} -f "$PGDUMP"
+}
+
+start() {
+ restore
+}
+
+stop() {
+ dump
+}
+