1 HELPERS="$HELPERS mysql:mysql_database_backup"
4 choose_one_vserver "$mysql_title"
6 mysql_vsname="vsname = $REPLY"
11 while [ -z "$REPLY" ]; do
12 formBegin "$mysql_title: databases"
24 [ $? = 0 ] || return 1
25 mysql_databases="databases = "
27 [ -n "$i" ] && mysql_databases="$mysql_databases $i"
33 inputBox "$mysql_title" "specify a mysql user:"
36 inputBox "$mysql_title" "specify the mysql user's password:"
39 do_mysql_final "dbusername = $user\ndbpassword = $password"
44 do_mysql_final "configfile = /etc/mysql/debian.cnf"
48 inputBox "$mysql_title" "what system user does mysql backup use?"
50 do_mysql_final "user = $REPLY"
54 if [ -z "$_DISABLE_HOTCOPY" ]; then
55 checkBox "$mysql_title" "check options" \
56 "sqldump" "create a backup using mysqldump (more compat)." no \
57 "hotcopy" "create a backup using mysqlhotcopy (faster)." yes \
58 "compress" "compress the sql output files" yes
60 sqldump="sqldump = no"
61 hotcopy="hotcopy = no"
63 checkBox "$mysql_title" "check options" \
64 "compress" "compress the sql output files" yes
66 sqldump="sqldump = yes"
67 hotcopy="hotcopy = no"
70 [ $status = 1 ] && return;
72 compress="compress = no"
73 for opt in $result; do
75 '"sqldump"') sqldump="sqldump = yes";;
76 '"hotcopy"') hotcopy="hotcopy = yes";;
77 '"compress"') compress="compress = yes";;
80 get_next_filename $configdirectory/20.mysql
82 cat >> $next_filename <<EOF
83 ### backupninja MySQL config file ###
85 # hotcopy = < yes | no > (default = no)
86 # make a backup of the actual database binary files using mysqlhotcopy.
89 # sqldump = < yes | no > (default = no)
90 # make a backup using mysqldump. this creates text files with sql commands
91 # sufficient to recontruct the database.
95 # compress = < yes | no > (default = yes)
96 # if yes, compress the sqldump output.
99 # dbhost = <host> (default = localhost)
102 cat >> $next_filename <<EOF
104 # backupdir = <dir> (default: /var/backups/mysql)
105 # where to dump the backups. hotcopy backups will be in a subdirectory
106 # 'hotcopy' and sqldump backups will be in a subdirectory 'sqldump'
109 # databases = <all | db1 db2 db3 > (default = all)
110 # which databases to backup. should either be the word 'all' or a
111 # space separated list of database names.
116 if [ $host_or_vservers == vservers ]
118 cat >> $next_filename <<EOF
120 # vsname = <vserver> (no default)
121 # vsname indicates which vserver to operate on, this is only used if
122 # vserver is set to yes in /etc/backupninja.conf
123 # NOTE: if you do not specify a vsname the host will be operated on
124 # alsoNOTE: if operating on a vserver, $VROOTDIR will be
125 # prepended to backupdir.
127 echo -e "$mysql_vsname\n" >> $next_filename
130 echo -e $@ >> $next_filename
132 chmod 600 $next_filename
138 mysql_title="MySQL action wizard"
140 # backup the host system or a Vserver?
141 choose_host_or_one_vserver "$mysql_title"
142 [ $? = 0 ] || return 1
143 if [ $host_or_vservers == vservers ]
146 [ $? = 0 ] || return 1
150 if [ $host_or_vservers == vservers ]
152 inputBox "$mysql_title" "Directory where to store the backups:`echo \"\n(Relative to chosen vserver's root directory)\"`" "/var/backups/mysql"
154 inputBox "$mysql_title" "Directory where to store the backups" "/var/backups/mysql"
157 mysql_backupdir="backupdir = $REPLY"
160 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.\"`"
162 mysql_databases="databases = all"
165 [ $? = 0 ] || return 1
170 menuBoxHelpFile "$mysql_title" "choose a mysql authentication method:" \
171 user "change to a linux user first." \
172 password "manually specify mysql user and password." \
173 debian "use default mysql user debian-sys-maint."
175 if [ $status = 2 ]; then
177 helptmp="/tmp/backupninja.help.$$"
179 To connect to mysql, backupninja must authenticate.
180 There are three possible authentication methods:
183 With this method, you specify a system user. Backupninja will
184 then become this user before running mysqldump or mysqlhotcopy.
185 The result is that ~/.my.cnf is used for authentication.
188 With this method, you manually specify a mysql user and
189 password in the backup action configuration.
192 With this method, we use the debian-sys-maint user which is
193 already defined in /etc/mysql/debian.cnf. If you are running
194 debian, this is recommended, because no further configuration
195 is needed. The drawback is that this is incompatible with
196 mysqlhotcopy: you must use mysqldump.
198 dialog --textbox $helptmp 0 0
202 [ $status = 1 ] && return;
205 "user") do_mysql_user;return;;
206 "password") do_mysql_password;return;;
207 "debian") do_mysql_debian;return;;