1
# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
3
HELPERS="$HELPERS pgsql:postgresql_database_backup"
6
choose_one_vserver "$pgsql_title"
8
pgsql_vsname="vsname = $REPLY"
11
do_pgsql_databases() {
13
while [ -z "$REPLY" ]; do
14
formBegin "$pgsql_title: databases"
26
[ $? = 0 ] || return 1
27
pgsql_databases="databases = "
29
[ -n "$i" ] && pgsql_databases="$pgsql_databases $i"
37
pgsql_title="PostgreSQL action wizard"
39
# backup the host system or a Vserver?
40
choose_host_or_one_vserver "$pgsql_title"
41
[ $? = 0 ] || return 1
42
if [ $host_or_vservers == vservers ]; then
44
[ $? = 0 ] || return 1
48
inputBox "$pgsql_title" "Directory where to store the backups:`[ -z \"$pgsql_vsname\" ] || echo \"\n(In respect to chosen vserver's root directory)\"`" "/var/backups/postgres"
50
pgsql_backupdir="backupdir = $REPLY"
53
booleanBox "$pgsql_title" "Do you want to backup the whole cluster? If not, you'll be offered to choose the databases to backup."
55
pgsql_databases="databases = all"
58
[ $? = 0 ] || return 1
62
booleanBox "$pgsql_title" "Do you want to compress the backups?"
64
pgsql_compress="compress = yes"
66
pgsql_compress="compress = no"
70
get_next_filename $configdirectory/20.pgsql
71
cat >> $next_filename <<EOF
72
### backupninja PostgreSQL config file ###
74
# vsname = <vserver> (no default)
75
# what vserver to operate on, only used if vserver = yes in /etc/backupninja.conf
76
# if you do not specify a vsname the host will be operated on
77
# Note: if operating on a vserver, $VROOTDIR will be prepended to backupdir.
79
if [ $host_or_vservers == vservers ]; then
80
echo -e "$pgsql_vsname\n" >> $next_filename
83
cat >> $next_filename <<EOF
84
# backupdir = <dir> (default: /var/backups/postgres)
85
# where to dump the backups
88
# databases = < all | db1 db2 db3 > (default = all)
89
# which databases to backup. should either be the word 'all' or a
90
# space separated list of database names.
91
# Note: when using 'all', pg_dumpall is used instead of pg_dump, which means
92
# that cluster-wide data (such as users and groups) are saved.
95
# compress = < yes | no > (default = yes)
96
# if yes, compress the pg_dump/pg_dumpall output.
99
### You can also set the following variables in backupninja.conf:
100
# PGSQLDUMP: pg_dump path (default: /usr/bin/pg_dump)
101
# PGSQLDUMPALL: pg_dumpall path (default: /usr/bin/pg_dumpall)
102
# PGSQLUSER: user running PostgreSQL (default: postgres)
105
chmod 600 $next_filename