aboutsummaryrefslogtreecommitdiffstats
path: root/community/postgresql-bdr/pgbdr-restore.initd
diff options
context:
space:
mode:
Diffstat (limited to 'community/postgresql-bdr/pgbdr-restore.initd')
-rw-r--r--community/postgresql-bdr/pgbdr-restore.initd36
1 files changed, 36 insertions, 0 deletions
diff --git a/community/postgresql-bdr/pgbdr-restore.initd b/community/postgresql-bdr/pgbdr-restore.initd
new file mode 100644
index 00000000000..27744396239
--- /dev/null
+++ b/community/postgresql-bdr/pgbdr-restore.initd
@@ -0,0 +1,36 @@
+#!/sbin/openrc-run
+
+extra_commands="${opts} dump restore purge"
+
+depend() {
+ need postgresql-bdr
+}
+
+restore() {
+ yesno "$PGDUMP" && return 0
+ ebegin "Restoring PostgreSQL $PGDUMP"
+ psql -U ${PG_USER:-postgres} ${PSQL_OPTS} -f "$PGDUMP" >/dev/null 2>/dev/null
+ local res=$?
+ yesno "$KEEP_DUMP" || rm -f "$PGDUMP"
+ eend $res
+ /etc/init.d/postgresql-bdr reload
+}
+
+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 $?
+}
+
+purge() {
+ yesno "$PGDUMP" && return 0
+ ebegin "Removing temporary $PGDUMP PostgreSQL backup"
+ rm -f "$PGDUMP"
+ eend $?
+}
+
+start() {
+ restore
+}