summaryrefslogtreecommitdiff
path: root/user/postgresql/pg-restore.initd
diff options
context:
space:
mode:
authorA. Wilcox <AWilcox@Wilcox-Tech.com>2018-06-14 02:22:19 -0500
committerA. Wilcox <AWilcox@Wilcox-Tech.com>2018-06-14 02:22:56 -0500
commitb1eb50599e4db7eb4501af75cbbfa22007081ea5 (patch)
treec94a34c882cc17adedd781e8c5f34349b2a62416 /user/postgresql/pg-restore.initd
parentb9e85bbdcf38547ef2ca4e5c2a6e6293bbcd2752 (diff)
downloadpackages-b1eb50599e4db7eb4501af75cbbfa22007081ea5.tar.gz
packages-b1eb50599e4db7eb4501af75cbbfa22007081ea5.tar.bz2
packages-b1eb50599e4db7eb4501af75cbbfa22007081ea5.tar.xz
packages-b1eb50599e4db7eb4501af75cbbfa22007081ea5.zip
The New Plan
all pkgs needed to bootstrap -> system others -> user
Diffstat (limited to 'user/postgresql/pg-restore.initd')
-rw-r--r--user/postgresql/pg-restore.initd36
1 files changed, 36 insertions, 0 deletions
diff --git a/user/postgresql/pg-restore.initd b/user/postgresql/pg-restore.initd
new file mode 100644
index 000000000..e9fe65c19
--- /dev/null
+++ b/user/postgresql/pg-restore.initd
@@ -0,0 +1,36 @@
+#!/sbin/openrc-run
+
+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
+}