1 # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
2 # vim: set filetype=sh sw=3 sts=3 expandtab autoindent:
4 HELPERS="$HELPERS pgsql:postgresql_database_backup"
7 choose_one_vserver "$pgsql_title"
9 pgsql_vsname="vsname = $REPLY"
12 do_pgsql_databases() {
14 while [ -z "$REPLY" ]; do
15 formBegin "$pgsql_title: databases"
27 [ $? = 0 ] || return 1
28 pgsql_databases="databases = "
30 [ -n "$i" ] && pgsql_databases="$pgsql_databases $i"
38 pgsql_title="PostgreSQL action wizard"
40 # backup the host system or a Vserver?
41 choose_host_or_one_vserver "$pgsql_title"
42 [ $? = 0 ] || return 1
43 if [ $host_or_vservers == vservers ]; then
45 [ $? = 0 ] || return 1
49 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"
51 pgsql_backupdir="backupdir = $REPLY"
54 booleanBox "$pgsql_title" "Do you want to backup the whole cluster? If not, you'll be offered to choose the databases to backup."
56 pgsql_databases="databases = all"
59 [ $? = 0 ] || return 1
63 booleanBox "$pgsql_title" "Do you want to compress the backups?"
65 pgsql_compress="compress = yes"
67 pgsql_compress="compress = no"
71 get_next_filename $configdirectory/20.pgsql
72 cat >> $next_filename <<EOF
73 ### backupninja PostgreSQL config file ###
75 # vsname = <vserver> (no default)
76 # what vserver to operate on, only used if vserver = yes in /etc/backupninja.conf
77 # if you do not specify a vsname the host will be operated on
78 # Note: if operating on a vserver, $VROOTDIR will be prepended to backupdir.
80 if [ $host_or_vservers == vservers ]; then
81 echo -e "$pgsql_vsname\n" >> $next_filename
84 cat >> $next_filename <<EOF
85 # backupdir = <dir> (default: /var/backups/postgres)
86 # where to dump the backups
89 # databases = < all | db1 db2 db3 > (default = all)
90 # which databases to backup. should either be the word 'all' or a
91 # space separated list of database names.
92 # Note: when using 'all', pg_dumpall is used instead of pg_dump, which means
93 # that cluster-wide data (such as users and groups) are saved.
96 # compress = < yes | no > (default = yes)
97 # if yes, compress the pg_dump/pg_dumpall output.
100 ### You can also set the following variables in backupninja.conf:
101 # PGSQLDUMP: pg_dump path (default: /usr/bin/pg_dump)
102 # PGSQLDUMPALL: pg_dumpall path (default: /usr/bin/pg_dumpall)
103 # PGSQLUSER: user running PostgreSQL (default: postgres)
106 chmod 600 $next_filename