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 # compress = < yes | no > (default = yes)
98 # if yes, compress the sqldump output.
101 # dbhost = <host> (default = localhost)
104 cat >> $next_filename <<EOF
106 # backupdir = <dir> (default: /var/backups/mysql)
107 # where to dump the backups. hotcopy backups will be in a subdirectory
108 # 'hotcopy' and sqldump backups will be in a subdirectory 'sqldump'
111 # databases = <all | db1 db2 db3 > (default = all)
112 # which databases to backup. should either be the word 'all' or a
113 # space separated list of database names.
118 if [ $host_or_vservers == vservers ]
120 cat >> $next_filename <<EOF
122 # vsname = <vserver> (no default)
123 # vsname indicates which vserver to operate on, this is only used if
124 # vserver is set to yes in /etc/backupninja.conf
125 # NOTE: if you do not specify a vsname the host will be operated on
126 # alsoNOTE: if operating on a vserver, $VROOTDIR will be
127 # prepended to backupdir.
129 echo -e "$mysql_vsname\n" >> $next_filename
132 echo -e $@ >> $next_filename
134 chmod 600 $next_filename
140 mysql_title="MySQL action wizard"
142 # backup the host system or a Vserver?
143 choose_host_or_one_vserver "$mysql_title"
144 [ $? = 0 ] || return 1
145 if [ $host_or_vservers == vservers ]
148 [ $? = 0 ] || return 1
152 if [ $host_or_vservers == vservers ]
154 inputBox "$mysql_title" "Directory where to store the backups:`echo \"\n(Relative to chosen vserver's root directory)\"`" "/var/backups/mysql"
156 inputBox "$mysql_title" "Directory where to store the backups" "/var/backups/mysql"
159 mysql_backupdir="backupdir = $REPLY"
162 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.\"`"
164 mysql_databases="databases = all"
167 [ $? = 0 ] || return 1
172 menuBoxHelpFile "$mysql_title" "choose a mysql authentication method:" \
173 user "change to a linux user first." \
174 password "manually specify mysql user and password." \
175 debian "use default mysql user debian-sys-maint."
177 if [ $status = 2 ]; then
179 helptmp="/tmp/backupninja.help.$$"
181 To connect to mysql, backupninja must authenticate.
182 There are three possible authentication methods:
185 With this method, you specify a system user. Backupninja will
186 then become this user before running mysqldump or mysqlhotcopy.
187 The result is that ~/.my.cnf is used for authentication.
190 With this method, you manually specify a mysql user and
191 password in the backup action configuration.
194 With this method, we use the debian-sys-maint user which is
195 already defined in /etc/mysql/debian.cnf. If you are running
196 debian, this is recommended, because no further configuration
197 is needed. The drawback is that this is incompatible with
198 mysqlhotcopy: you must use mysqldump.
200 dialog --textbox $helptmp 0 0
204 [ $status = 1 ] && return;
207 "user") do_mysql_user;return;;
208 "password") do_mysql_password;return;;
209 "debian") do_mysql_debian;return;;