blob: 3d1ad50f6dce154aa15e4bb9c39bdcc254c82262 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#!/sbin/runscript
. /etc/conf.d/postgresql
opts="${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
yesno "$KEEP_DUMP" || rm -f "$PGDUMP"
su -l ${PGUSER} \
-c "env PGDATA=\"${PGDATA}\" /usr/bin/pg_ctl reload " >/dev/null
eend $res
}
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
}
stop() {
dump
}
|