3 # Display a form for backing up this database, or all databases
5 require './mysql-lib.pl';
8 @alldbs = &list_databases();
9 @dbs = grep { &can_edit_db($_) } @alldbs;
10 @alldbs == @dbs || &error($text{'dbase_ecannot'});
13 &can_edit_db($in{'db'}) || &error($text{'dbase_ecannot'});
15 $access{'edonly'} && &error($text{'dbase_ecannot'});
16 $access{'buser'} || &error($text{'dbase_ecannot'});
17 &ui_print_header(undef, $in{'all'} ? $text{'backup_title2'}
18 : $text{'backup_title'}, "",
21 if (!-x $config{'mysqldump'}) {
22 print &text('backup_edump', "<tt>$config{'mysqldump'}</tt>",
23 "../config.cgi?$module_name"),"<p>\n";
24 &ui_print_footer("edit_dbase.cgi?db=$in{'db'}", $text{'dbase_return'});
28 $cron = !$module_info{'usermin'} && $access{'buser'} eq 'root' &&
29 !$access{'user'} && &foreign_installed("cron");
31 print "$text{'backup_desc3'}\n";
34 print &text('backup_desc', "<tt>$in{'db'}</tt>"),"\n";
37 print "$text{'backup_desc2'}\n";
40 %c = $module_info{'usermin'} ? %userconfig : %config;
42 print &ui_form_start("backup_db.cgi", "post");
43 print &ui_hidden("db", $in{'db'});
44 print &ui_hidden("all", $in{'all'});
45 print &ui_hidden_table_start($text{'backup_header1'}, "width=100%", 2, "main",
48 # Destination file or directory
49 print &ui_table_row($in{'all'} ? $text{'backup_file2'}
50 : $text{'backup_file'},
51 &ui_textbox("file", $c{'backup_'.$in{'db'}}, 60)." ".
52 &file_chooser_button("file"));
54 # Create destination dir
56 print &ui_table_row($text{'backup_mkdir'},
57 &ui_yesno_radio("mkdir", int($c{'backup_mkdir_'.$in{'db'}})));
61 # Show input to select tables
62 $t = $c{'backup_tables_'.$in{'db'}};
63 @tables = &list_tables($in{'db'});
64 print &ui_table_row($text{'backup_tables'},
65 &ui_radio("tables_def", $t ? 0 : 1,
66 [ [ 1, $text{'backup_alltables'} ],
67 [ 0, $text{'backup_seltables'} ] ])."<br>".
68 &ui_select("tables", [ split(/\s+/, $t) ],
69 [ sort @tables ], 5, 1));
72 print &ui_hidden_table_end("main");
73 print &ui_hidden_table_start($text{'backup_header2'}, "width=100%", 2, "opts",
76 # Show input for where clause
77 $w = $c{'backup_where_'.$in{'db'}};
78 print &ui_table_row($text{'backup_where'},
79 &ui_opt_textbox("where", $w, 30, $text{'backup_none'}));
81 # Show option to include drop statements in SQL
82 $d = $c{'backup_drop_'.$in{'db'}};
83 print &ui_table_row($text{'backup_drop'},
84 &ui_yesno_radio("drop", $d ? 1 : 0));
86 # Show input for character set
87 $s = $c{'backup_charset_'.$in{'db'}};
88 print &ui_table_row($text{'backup_charset'},
89 &ui_radio("charset_def", $s ? 0 : 1,
90 [ [ 1, $text{'default'} ],
91 [ 0, &ui_select("charset", $s,
92 [ &list_character_sets($in{'db'}) ]) ] ]));
94 if ($mysql_version >= 5.0) {
95 # Show compatability format option
96 $cf = $c{'backup_compatible_'.$in{'db'}};
97 print &ui_table_row($text{'backup_compatible'},
98 &ui_radio("compatible_def", $cf ? 0 : 1,
99 [ [ 1, $text{'default'} ],
100 [ 0, &text('backup_compwith',
101 &ui_select("compatible", $cf,
102 [ &list_compatible_formats() ])) ] ]));
104 %co = map { $_, 1 } split(/\s+/, $c{'backup_options_'.$in{'db'}});
106 foreach $o (&list_compatible_options()) {
107 $opts .= &ui_checkbox("options", $o->[0], $o->[1] || $o->[0],
108 $co{$o->[0]})."<br>\n";
110 print &ui_table_row($text{'backup_options'}, $opts);
113 print &ui_hidden("compatible_def", 1),"\n";
116 # Show compression option
117 $cp = int($c{'backup_compress_'.$in{'db'}});
118 print &ui_table_row($text{'backup_compress'},
119 &ui_radio("compress", $cp,
120 [ [ 0, $text{'backup_cnone'} ],
121 [ 1, $text{'backup_gzip'} ],
122 [ 2, $text{'backup_bzip2'} ] ]));
124 # Show single-transaction option
125 $s = $c{'backup_single_'.$in{'db'}};
126 print &ui_table_row($text{'backup_single'},
127 &ui_yesno_radio("single", $s ? 1 : 0));
130 # Show before/after commands
131 $b = $c{'backup_before_'.$in{'db'}};
132 print &ui_table_row($text{'backup_before'},
133 &ui_textbox("before", $b, 60));
135 $a = $c{'backup_after_'.$in{'db'}};
136 print &ui_table_row($text{'backup_after'},
137 &ui_textbox("after", $a, 60));
140 # Command mode option
141 $cmode = $c{'backup_cmode_'.$in{'db'}};
142 print &ui_table_row($text{'backup_cmode'},
143 &ui_radio("cmode", int($cmode),
144 [ [ 0, $text{'backup_cmode0'} ],
145 [ 1, $text{'backup_cmode1'} ] ]));
148 print &ui_hidden_table_end("opts");
149 print &ui_hidden_table_start($text{'backup_header3'}, "width=100%", 2,
150 "sched", 1, [ "width=30%" ]);
153 &foreign_require("cron", "cron-lib.pl");
154 @jobs = &cron::list_cron_jobs();
155 $cmd = $in{'all'} ? "$cron_cmd --all" : "$cron_cmd $in{'db'}";
156 ($job) = grep { $_->{'command'} eq $cmd } @jobs;
158 print &ui_table_row($text{'backup_sched'},
159 &ui_radio("sched", $job ? 1 : 0,
160 [ [ 0, $text{'no'} ], [ 1, $text{'backup_sched1'} ] ]));
162 $job ||= { 'mins' => 0,
167 print &ui_table_row(undef,
168 "<table border=2 width=100%>".
169 &capture_function_output(\&cron::show_times_input, $job).
172 print &ui_hidden_table_end("sched");
175 print &ui_hidden_table_end("opts");
179 print &ui_form_end([ [ "backup", $text{'backup_ok'} ],
180 [ "save", $text{'backup_ok2'} ] ]);
183 print &ui_form_end([ [ "backup", $text{'backup_ok'} ] ]);
187 &ui_print_footer("", $text{'index_return'});
190 &ui_print_footer("edit_dbase.cgi?db=$in{'db'}", $text{'dbase_return'},
191 "", $text{'index_return'});