aboutsummaryrefslogtreecommitdiffstats
path: root/testing/postgresql-bdr/pgbdr-restore.initd
diff options
context:
space:
mode:
authorLeonardo Arena <rnalrd@alpinelinux.org>2015-02-26 15:16:34 +0000
committerLeonardo Arena <rnalrd@alpinelinux.org>2015-02-26 15:16:34 +0000
commit9d8bf660a253655efcefd01a3482a922d7b4833e (patch)
tree335c86b4ec6c930099dfd1d5bc6cb19ef88859e2 /testing/postgresql-bdr/pgbdr-restore.initd
parent69473427baeeb35538cbedff983e8d4d2248b8d8 (diff)
downloadaports-9d8bf660a253655efcefd01a3482a922d7b4833e.tar.bz2
aports-9d8bf660a253655efcefd01a3482a922d7b4833e.tar.xz
testing/postgresql-bdr: new aport
PostgreSQL with bidirection replication
Diffstat (limited to 'testing/postgresql-bdr/pgbdr-restore.initd')
-rw-r--r--testing/postgresql-bdr/pgbdr-restore.initd36
1 files changed, 36 insertions, 0 deletions
diff --git a/testing/postgresql-bdr/pgbdr-restore.initd b/testing/postgresql-bdr/pgbdr-restore.initd
new file mode 100644
index 0000000000..f6075bca2d
--- /dev/null
+++ b/testing/postgresql-bdr/pgbdr-restore.initd
@@ -0,0 +1,36 @@
+#!/sbin/runscript
+
+extra_commands="${opts} dump restore purge"
+
+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
+ local res=$?
+ yesno "$KEEP_DUMP" || rm -f "$PGDUMP"
+ eend $res
+ /etc/init.d/postgresql 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
+}