aboutsummaryrefslogtreecommitdiffstats
path: root/main/postgresql/pg-restore.initd
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2010-03-29 12:28:31 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2010-03-29 12:28:31 +0000
commit64bce71141d9562664c0a852dd096978579ea5f8 (patch)
tree860c2a014423669b54fd94980c46833cfefa55cc /main/postgresql/pg-restore.initd
parent09838439c042827adfa17b7cf387729c9bc03f71 (diff)
downloadaports-64bce71141d9562664c0a852dd096978579ea5f8.tar.bz2
aports-64bce71141d9562664c0a852dd096978579ea5f8.tar.xz
main/postgresql: depend on client. added pg-restore init.d script
New feature to restore backe up databases on bootup. Helps when you run postgresql databases from tmpfs.
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
+}
+