1 # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
2 HELPERS="$HELPERS mysql:mysql_database_backup"
5 choose_one_vserver "$mysql_title"
7 mysql_vsname="vsname = $REPLY"
10 do_mysql_databases() {
12 while [ -z "$REPLY" ]; do
13 formBegin "$mysql_title: databases"
25 [ $? = 0 ] || return 1
26 mysql_databases="databases = "
28 [ -n "$i" ] && mysql_databases="$mysql_databases $i"
34 inputBox "$mysql_title" "specify a mysql user:"
37 inputBox "$mysql_title" "specify the mysql user's password:"
40 do_mysql_final "dbusername = $user\ndbpassword = $password"
45 do_mysql_final "configfile = /etc/mysql/debian.cnf"
49 inputBox "$mysql_title" "what system user does mysql backup use?"
51 do_mysql_final "user = $REPLY"
55 if [ -z "$_DISABLE_HOTCOPY" ]; then
56 checkBox "$mysql_title" "check options" \
57 "sqldump" "create a backup using mysqldump (more compat)." no \
58 "hotcopy" "create a backup using mysqlhotcopy (faster)." yes \
59 "compress" "compress the sql output files" yes
61 sqldump="sqldump = no"
62 hotcopy="hotcopy = no"
64 checkBox "$mysql_title" "check options" \
65 "compress" "compress the sql output files" yes
67 sqldump="sqldump = yes"
68 hotcopy="hotcopy = no"
71 [ $status = 1 ] && return;
73 compress="compress = no"
74 for opt in $result; do
76 '"sqldump"') sqldump="sqldump = yes";;
77 '"hotcopy"') hotcopy="hotcopy = yes";;
78 '"compress"') compress="compress = yes";;
81 get_next_filename $configdirectory/20.mysql
83 cat >> $next_filename <<EOF
84 ### backupninja MySQL config file ###
86 # hotcopy = < yes | no > (default = no)
87 # make a backup of the actual database binary files using mysqlhotcopy.
90 # sqldump = < yes | no > (default = no)
91 # make a backup using mysqldump. this creates text files with sql commands
92 # sufficient to recontruct the database.
96 # compress = < yes | no > (default = yes)
97 # if yes, compress the sqldump output.
100 # dbhost = <host> (default = localhost)
103 cat >> $next_filename <<EOF
105 # backupdir = <dir> (default: /var/backups/mysql)
106 # where to dump the backups. hotcopy backups will be in a subdirectory
107 # 'hotcopy' and sqldump backups will be in a subdirectory 'sqldump'
110 # databases = <all | db1 db2 db3 > (default = all)
111 # which databases to backup. should either be the word 'all' or a
112 # space separated list of database names.
117 if [ $host_or_vservers == vservers ]
119 cat >> $next_filename <<EOF
121 # vsname = <vserver> (no default)
122 # vsname indicates which vserver to operate on, this is only used if
123 # vserver is set to yes in /etc/backupninja.conf
124 # NOTE: if you do not specify a vsname the host will be operated on
125 # alsoNOTE: if operating on a vserver, $VROOTDIR will be
126 # prepended to backupdir.
128 echo -e "$mysql_vsname\n" >> $next_filename
131 echo -e $@ >> $next_filename
133 chmod 600 $next_filename
139 mysql_title="MySQL action wizard"
141 # backup the host system or a Vserver?
142 choose_host_or_one_vserver "$mysql_title"
143 [ $? = 0 ] || return 1
144 if [ $host_or_vservers == vservers ]
147 [ $? = 0 ] || return 1
151 if [ $host_or_vservers == vservers ]
153 inputBox "$mysql_title" "Directory where to store the backups:`echo \"\n(Relative to chosen vserver's root directory)\"`" "/var/backups/mysql"
155 inputBox "$mysql_title" "Directory where to store the backups" "/var/backups/mysql"
158 mysql_backupdir="backupdir = $REPLY"
161 booleanBox "$mysql_title" "Do you want to backup all of the databases? `echo \"\n\nIf not, you'll be offered to choose individual databases to backup.\"`"
163 mysql_databases="databases = all"
166 [ $? = 0 ] || return 1
171 menuBoxHelpFile "$mysql_title" "choose a mysql authentication method:" \
172 user "change to a linux user first." \
173 password "manually specify mysql user and password." \
174 debian "use default mysql user debian-sys-maint."
176 if [ $status = 2 ]; then
178 helptmp="/tmp/backupninja.help.$$"
180 To connect to mysql, backupninja must authenticate.
181 There are three possible authentication methods:
184 With this method, you specify a system user. Backupninja will
185 then become this user before running mysqldump or mysqlhotcopy.
186 The result is that ~/.my.cnf is used for authentication.
189 With this method, you manually specify a mysql user and
190 password in the backup action configuration.
193 With this method, we use the debian-sys-maint user which is
194 already defined in /etc/mysql/debian.cnf. If you are running
195 debian, this is recommended, because no further configuration
196 is needed. The drawback is that this is incompatible with
197 mysqlhotcopy: you must use mysqldump.
199 dialog --textbox $helptmp 0 0
203 [ $status = 1 ] && return;
206 "user") do_mysql_user;return;;
207 "password") do_mysql_password;return;;
208 "debian") do_mysql_debian;return;;