~ubuntu-branches/ubuntu/karmic/backupninja/karmic

« back to all changes in this revision

Viewing changes to handlers/pgsql.helper

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2007-12-05 15:42:47 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20071205154247-w6r1xld7160156nx
Tags: 0.9.5-2
* Fixed ignore_version default value in rdiff handler
* Updated standards version to 3.7.3 (no changes)
* Removed unused /usr/bin from debian/backupninja.dirs

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
2
 
 
3
 
HELPERS="$HELPERS pgsql:postgresql_database_backup"
4
 
 
5
 
do_pgsql_vserver() {
6
 
   choose_one_vserver "$pgsql_title"
7
 
   [ $? = 0 ] || return 1
8
 
   pgsql_vsname="vsname = $REPLY"
9
 
}
10
 
 
11
 
do_pgsql_databases() {
12
 
   REPLY=
13
 
   while [ -z "$REPLY" ]; do
14
 
      formBegin "$pgsql_title: databases"
15
 
         formItem "Database:"
16
 
         formItem "Database:"
17
 
         formItem "Database:"
18
 
         formItem "Database:"
19
 
         formItem "Database:"
20
 
         formItem "Database:"
21
 
         formItem "Database:"
22
 
         formItem "Database:"
23
 
         formItem "Database:"
24
 
         formItem "Database:"
25
 
      formDisplay
26
 
      [ $? = 0 ] || return 1
27
 
      pgsql_databases="databases = "
28
 
      for i in $REPLY; do
29
 
         [ -n "$i" ] && pgsql_databases="$pgsql_databases $i"
30
 
      done
31
 
   done
32
 
}
33
 
 
34
 
pgsql_wizard() {
35
 
 
36
 
    # constants
37
 
   pgsql_title="PostgreSQL action wizard"
38
 
 
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
43
 
      do_pgsql_vserver
44
 
      [ $? = 0 ] || return 1
45
 
   fi
46
 
 
47
 
   # backupdir
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"
49
 
   [ $? = 1 ] && return
50
 
   pgsql_backupdir="backupdir = $REPLY"
51
 
 
52
 
   # databases
53
 
   booleanBox "$pgsql_title" "Do you want to backup the whole cluster? If not, you'll be offered to choose the databases to backup."
54
 
   if [ $? = 0 ]; then
55
 
      pgsql_databases="databases = all"
56
 
   else
57
 
      do_pgsql_databases
58
 
      [ $? = 0 ] || return 1
59
 
   fi
60
 
 
61
 
   # compress
62
 
   booleanBox "$pgsql_title" "Do you want to compress the backups?"
63
 
   if [ $? = 0 ]; then
64
 
      pgsql_compress="compress = yes"
65
 
   else
66
 
      pgsql_compress="compress = no"
67
 
   fi
68
 
 
69
 
   # write config file
70
 
   get_next_filename $configdirectory/20.pgsql
71
 
   cat >> $next_filename <<EOF
72
 
### backupninja PostgreSQL config file ###
73
 
 
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.
78
 
EOF
79
 
   if [ $host_or_vservers == vservers ]; then
80
 
      echo -e "$pgsql_vsname\n" >> $next_filename
81
 
   fi
82
 
 
83
 
   cat >> $next_filename <<EOF
84
 
# backupdir = <dir> (default: /var/backups/postgres)
85
 
# where to dump the backups
86
 
$pgsql_backupdir
87
 
 
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.
93
 
$pgsql_databases
94
 
 
95
 
# compress = < yes | no > (default = yes)
96
 
# if yes, compress the pg_dump/pg_dumpall output. 
97
 
$pgsql_compress
98
 
 
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)
103
 
 
104
 
EOF
105
 
   chmod 600 $next_filename
106
 
 
107
 
}