1 # -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
3 HELPERS="$HELPERS mysql:mysql_database_backup"
6 choose_one_vserver "$mysql_title"
8 mysql_vsname="vsname = $REPLY"
11 do_mysql_databases() {
13 while [ -z "$REPLY" ]; do
14 formBegin "$mysql_title: databases"
26 [ $? = 0 ] || return 1
27 mysql_databases="databases = "
29 [ -n "$i" ] && mysql_databases="$mysql_databases $i"
35 inputBox "$mysql_title" "specify a mysql user:"
38 inputBox "$mysql_title" "specify the mysql user's password:"
41 do_mysql_final "dbusername = $user\ndbpassword = $password"
46 do_mysql_final "configfile = /etc/mysql/debian.cnf"
50 inputBox "$mysql_title" "what system user does mysql backup use?"
52 do_mysql_final "user = $REPLY"
56 if [ -z "$_DISABLE_HOTCOPY" ]; then
57 checkBox "$mysql_title" "check options" \
58 "sqldump" "create a backup using mysqldump (more compat)." no \
59 "hotcopy" "create a backup using mysqlhotcopy (faster)." yes \
60 "compress" "compress the sql output files" yes
62 sqldump="sqldump = no"
63 hotcopy="hotcopy = no"
65 checkBox "$mysql_title" "check options" \
66 "compress" "compress the sql output files" yes
68 sqldump="sqldump = yes"
69 hotcopy="hotcopy = no"
72 [ $status = 1 ] && return;
74 compress="compress = no"
75 for opt in $result; do
77 '"sqldump"') sqldump="sqldump = yes";;
78 '"hotcopy"') hotcopy="hotcopy = yes";;
79 '"compress"') compress="compress = yes";;
82 get_next_filename $configdirectory/20.mysql
84 cat >> $next_filename <<EOF
85 ### backupninja MySQL config file ###
87 # hotcopy = < yes | no > (default = no)
88 # make a backup of the actual database binary files using mysqlhotcopy.
91 # sqldump = < yes | no > (default = no)
92 # make a backup using mysqldump. this creates text files with sql commands
93 # sufficient to recontruct the database.
97 # sqldumpoptions = <options>
98 # (default = --lock-tables --complete-insert --add-drop-table --quick --quote-names)
99 # arguments to pass to mysqldump
100 # sqldumpoptions = --add-drop-table --quick --quote-names
102 # compress = < yes | no > (default = yes)
103 # if yes, compress the sqldump output.
106 # dbhost = <host> (default = localhost)
109 cat >> $next_filename <<EOF
111 # backupdir = <dir> (default: /var/backups/mysql)
112 # where to dump the backups. hotcopy backups will be in a subdirectory
113 # 'hotcopy' and sqldump backups will be in a subdirectory 'sqldump'
116 # databases = <all | db1 db2 db3 > (default = all)
117 # which databases to backup. should either be the word 'all' or a
118 # space separated list of database names.
123 if [ $host_or_vservers == vservers ]
125 cat >> $next_filename <<EOF
127 # vsname = <vserver> (no default)
128 # vsname indicates which vserver to operate on, this is only used if
129 # vserver is set to yes in /etc/backupninja.conf
130 # NOTE: if you do not specify a vsname the host will be operated on
131 # alsoNOTE: if operating on a vserver, $VROOTDIR will be
132 # prepended to backupdir.
134 echo -e "$mysql_vsname\n" >> $next_filename
137 echo -e $@ >> $next_filename
139 chmod 600 $next_filename
145 mysql_title="MySQL action wizard"
147 # backup the host system or a Vserver?
148 choose_host_or_one_vserver "$mysql_title"
149 [ $? = 0 ] || return 1
150 if [ $host_or_vservers == vservers ]
153 [ $? = 0 ] || return 1
157 if [ $host_or_vservers == vservers ]
159 inputBox "$mysql_title" "Directory where to store the backups:`echo \"\n(Relative to chosen vserver's root directory)\"`" "/var/backups/mysql"
161 inputBox "$mysql_title" "Directory where to store the backups" "/var/backups/mysql"
164 mysql_backupdir="backupdir = $REPLY"
167 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.\"`"
169 mysql_databases="databases = all"
172 [ $? = 0 ] || return 1
177 menuBoxHelpFile "$mysql_title" "choose a mysql authentication method:" \
178 user "change to a linux user first." \
179 password "manually specify mysql user and password." \
180 debian "use default mysql user debian-sys-maint."
182 if [ $status = 2 ]; then
184 helptmp="/tmp/backupninja.help.$$"
186 To connect to mysql, backupninja must authenticate.
187 There are three possible authentication methods:
190 With this method, you specify a system user. Backupninja will
191 then become this user before running mysqldump or mysqlhotcopy.
192 The result is that ~/.my.cnf is used for authentication.
195 With this method, you manually specify a mysql user and
196 password in the backup action configuration.
199 With this method, we use the debian-sys-maint user which is
200 already defined in /etc/mysql/debian.cnf. If you are running
201 debian, this is recommended, because no further configuration
202 is needed. The drawback is that this is incompatible with
203 mysqlhotcopy: you must use mysqldump.
205 dialog --textbox $helptmp 0 0
209 [ $status = 1 ] && return;
212 "user") do_mysql_user;return;;
213 "password") do_mysql_password;return;;
214 "debian") do_mysql_debian;return;;