#!/usr/local/bin/perl # backup_form.cgi # Display a form for backup the database require './postgresql-lib.pl' ; &ReadParse(); &error_setup ( $text{'backup_err'} ) ; if ($in{'all'}) { @alldbs = &list_databases(); @dbs = grep { &can_edit_db($_) } @alldbs; @alldbs == @dbs || &error($text{'dbase_ecannot'}); } else { &can_edit_db($in{'db'}) || &error($text{'dbase_ecannot'}); } $access{'backup'} || &error($text{'backup_ecannot'}); &has_command($config{'dump_cmd'}) || &error(&text('backup_ecmd', "$config{'dump_cmd'}")); $desc = "$in{'db'}"; &ui_print_header($desc, $in{'all'} ? $text{'backup_title2'} : $text{'backup_title'}, "", "backup_form" ) ; $cron = !$module_info{'usermin'} && !$access{'user'} && &foreign_installed("cron"); if ($in{'all'}) { print "$text{'backup_desc3'}\n"; } else { print &text('backup_desc', "$in{'db'}"),"\n"; } if ($cron) { print "$text{'backup_desc2'}\n"; } print "

\n"; %c = $module_info{'usermin'} ? %userconfig : %config; print "

\n" ; print "\n" ; print "\n" ; print "\n" ; print "\n" ; print "
$text{'backup_header'}
\n" ; $p = $c{'backup_'.$in{'db'}} || "$config{'repository'}/"; if ($in{'all'}) { print "\n" ; } else { print "\n" ; } print "\n" ; # Show backup format input $f = $c{'backup_format_'.$in{'db'}}; print "\n"; print "\n"; if (!$in{'all'}) { # Show input to select tables $t = $c{'backup_tables_'.$in{'db'}}; print "\n"; } if ($cron) { if ($access{'cmds'}) { $b = $c{'backup_before_'.$in{'db'}}; print "\n"; print "\n"; $a = $c{'backup_after_'.$in{'db'}}; print "\n"; print "\n"; if ($in{'all'}) { # Command mode option $a = $c{'backup_cmode_'.$in{'db'}}; print "\n"; print "\n"; } } &foreign_require("cron", "cron-lib.pl"); @jobs = &cron::list_cron_jobs(); $cmd = $in{'all'} ? "$cron_cmd --all" : "$cron_cmd $in{'db'}"; ($job) = grep { $_->{'command'} eq $cmd } @jobs; print "\n"; printf "\n", $job ? "checked" : "", $text{'backup_sched1'}; if (!$config{'simple_sched'} || ($dump && !$dump->{'special'})) { # Complex Cron time input print "\n"; } else { # Simple Cron time input $job ||= { 'special' => 'daily' }; print &ui_hidden("special_def", 1),"\n"; print "\n"; print "\n"; } } print "
$text{'backup_path2'}
$text{'backup_path'}", &file_chooser_button("path"),"
$text{'backup_format'}
$text{'backup_tables'} \n"; printf " %s\n", $t ? "" : "checked", $text{'backup_alltables'}; printf " %s\n", $t ? "checked" : "", $text{'backup_seltables'}; @tables = &list_tables($in{'db'}); %got = map { $_, 1 } split(/\s+/, $t); print "
$text{'backup_before'}",&ui_textbox("before", $b, 50),"
$text{'backup_after'}",&ui_textbox("after", $a, 50),"
$text{'backup_cmode'}",&ui_radio("cmode", int($cmode), [ [ 0, $text{'backup_cmode0'} ], [ 1, $text{'backup_cmode1'} ] ]), "
$text{'backup_sched'} %s\n", $job ? "" : "checked", $text{'no'}; printf " %s
\n"; $job ||= { 'mins' => 0, 'hours' => 0, 'days' => '*', 'months' => '*', 'weekdays' => '*' }; &cron::show_times_input($job); print "
$text{'backup_special'}",&ui_select("special", $job->{'special'}, [ map { [ $_, $cron::text{'edit_special_'.$_} ] } ('hourly', 'daily', 'weekly', 'monthly', 'yearly') ]), "
\n" ; if ($cron) { print "\n"; print "\n"; } else { print "\n"; } print "
\n"; print "
\n"; if ($in{'all'}) { &ui_print_footer("", $text{'index_return'}); } else { &ui_print_footer("edit_dbase.cgi?db=$in{'db'}", $text{'dbase_return'}, "", $text{'index_return'}); }