--- ./drakbackup.bad 2002-10-15 13:11:27.000000000 -0400 +++ ./drakbackup 2003-05-06 09:12:25.000000000 -0400 @@ -123,14 +123,11 @@ use standalone; #- warning, standalone must be loaded very first, for 'explanations' use interactive; -use my_gtk qw(:helpers :wrappers); use common; use Time::localtime; use detect_devices; -my $in = 'interactive'->vnew('', 'default'); - if ("@ARGV" =~ /--help|-h/) { print q(Backup and Restore application @@ -281,6 +278,7 @@ # allow not-root user with own config if ($ENV{USER} ne 'root') { + standalone::explanations("Running as $ENV{USER}..."); $cfg_dir = "$user_home/.drakbackup/"; $save_path = $cfg_dir . "backups"; -d $save_path or mkdir_p $save_path; @@ -597,7 +595,7 @@ $del_hd_files and push @cfg_list, "DEL_HD_FILES\n" ; output_p($cfg_file, @cfg_list); chmod(0600, $cfg_file); - save_cron_files() if ($backup_daemon); + save_cron_files(); } sub read_cron_files { @@ -619,7 +617,7 @@ $backup_daemon = 0; return(1); } - my @cron_file = ("#!/bin/sh\n", "export TERM=xterm\n", "/usr/sbin/drakbackup --daemon > /dev/null 2>&1\n"); + my @cron_file = ("#!/bin/sh\n", "export USER=root\n", "/usr/sbin/drakbackup --daemon > /dev/null 2>&1\n"); if ($backup_daemon) { foreach (qw(hourly daily weekly monthly)) { @@ -1197,7 +1195,7 @@ -d $save_path and @dir_content = all($save_path); grep (/^backup\_base\_sys/, @dir_content) and $base_sys_exist = 1; - if (($where_hd && !$daemon) || ($daemon && ($daemon_media eq 'hd'))) { + if (($where_hd && !$daemon) || ($daemon)) { $interactive and progress($pbar, 0.5, _("Backup system files...")); if ($backup_sys) { if ($backup_sys_versions) { @@ -1247,23 +1245,59 @@ } } - $interactive and progress($pbar, 0.5, _("Backup system files...")); - $interactive and progress($pbar3, 0.3, _("Hard Disk Backup files...")); + $interactive and progress($pbar, 0.5, _("Backup system files...")); + $interactive and progress($pbar3, 0.3, _("Hard Disk Backup files...")); - if (@list_other) { - system("cd $save_path && rm -f backup_other* "); - system("$tar_cmd_other -f $save_path/backup_other$the_time.$tar_ext @list_other"); - push @file_list_to_send_by_ftp, "$save_path/backup_other$the_time.$tar_ext"; - $results .= "\nfile: $save_path/backup_other$the_time.$tar_ext\n"; - #old foreach (@list_other) { push @list_other_, $_ . "\n"; } - @list_other_ = map { "$_\n" } @list_other; - output_p($save_path . '/list_other', @list_other_); - } + if (@list_other) { + if ($backup_other_versions) { + if (grep /^list\_incr\_other/, @dir_content) { + my @more_recent = grep /^list\_incr\_other/, sort @dir_content; + $more_recent = pop @more_recent; + $DEBUG and print "more recent file: $more_recent\n"; + system("find @list_other -cnewer $save_path/$more_recent \! -type d -print > $save_path/list_incr_other$the_time.txt"); + if (!cat_("$save_path/list_incr_other$the_time.txt")) { + system("rm $save_path/list_incr_other$the_time.txt"); + } else { + system("$tar_cmd_other -f $save_path/backup_incr_other$the_time.$tar_ext -T $save_path/list_incr_other$the_time.txt"); + push @file_list_to_send_by_ftp, "$save_path/backup_incr_other$the_time.$tar_ext"; + push @file_list_to_send_by_ftp, "$save_path/list_incr_other$the_time.txt"; + $results .= "\nfile: $save_path/backup_incr_other$the_time.$tar_ext\n"; + $results .= cat_("$save_path/list_incr_other$the_time.txt"); + } + } elsif (grep /^list\_base\_other/, @dir_content) { + my @more_recent = grep /^list\_base\_other/, sort @dir_content; + $more_recent = pop @more_recent; + $DEBUG and print "more recent file: $more_recent\n"; + system("find @list_other -cnewer $save_path/$more_recent \! -type d -print > $save_path/list_incr_other$the_time.txt"); + if (!cat_("$save_path/list_incr_other$the_time.txt")) { + system("rm $save_path/list_incr_other$the_time.txt"); + } else { + system("$tar_cmd_other -f $save_path/backup_incr_other$the_time.$tar_ext -T $save_path/list_incr_other$the_time.txt"); + push @file_list_to_send_by_ftp, "$save_path/backup_incr_other$the_time.$tar_ext"; + push @file_list_to_send_by_ftp, "$save_path/list_incr_other$the_time.txt"; + $results .= "\nfile: $save_path/backup_incr_other$the_time.$tar_ext\n"; + $results .= cat_("$save_path/list_incr_other$the_time.txt"); + } + } else { + #- need this for the first pass too, if we're offloading the backups to other media (sb) + system("find @list_other \! -type d -print > $save_path/list_base_other$the_time.txt"); + system("$tar_cmd_other -f $save_path/backup_base_other$the_time.$tar_ext @list_other"); + push @file_list_to_send_by_ftp, "$save_path/backup_base_other$the_time.$tar_ext"; + push @file_list_to_send_by_ftp, "$save_path/list_base_other$the_time.txt"; + $results .= "\nfile: $save_path/backup_base_other$the_time.$tar_ext\n"; + } + } else { + system("cd $save_path && rm -f backup_other* backup_base_other* backup_incr_other*"); + system("$tar_cmd_other -f $save_path/backup_other$the_time.$tar_ext @list_other"); + push @file_list_to_send_by_ftp, "$save_path/backup_other$the_time.$tar_ext"; + $results .= "\nfile: $save_path/backup_other$the_time.$tar_ext\n"; + } + } - $interactive and progress($pbar1, 1, _("Backup User files...")); - $interactive and progress($pbar3, 0.3, _("Hard Disk Backup Progress...")); + $interactive and progress($pbar2, 1, _("Backup Other files...")); + $interactive and progress($pbar3, 0.4, _("Hard Disk Backup files...")); - if ($backup_user) { + if ($backup_user) { foreach (@user_list) { my $user = $_; $path_name = return_path($user); @@ -1306,16 +1340,16 @@ push @file_list_to_send_by_ftp, "$save_path/list_base_user_$user$the_time.txt"; $results .= "\nfile: $save_path/backup_base_user_$user$the_time.$tar_ext\n"; } - } else { + } else { system("cd $save_path && rm -f backup_user_$_* backup_base_user_$_* backup_incr_user_$_*"); system("$tar_cmd_user -f $save_path/backup_user_$_$the_time.$tar_ext $path_name"); push @file_list_to_send_by_ftp, "$save_path/backup_user_$_$the_time.$tar_ext"; $results .= "\nfile: $save_path/backup_user_$user$the_time.$tar_ext\n"; - } + } + } } - } - $interactive and progress($pbar2, 1, _("Backup Other files...")); - $interactive and progress($pbar3, 0.4, _("Hard Disk Backup files...")); + $interactive and progress($pbar1, 1, _("Backup User files...")); + $interactive and progress($pbar3, 0.3, _("Hard Disk Backup Progress...")); } my $filecount = @file_list_to_send_by_ftp; @@ -1673,7 +1707,7 @@ gtksignal_connect(new Gtk::Button(_("Add")), clicked => sub { filedialog() }), gtksignal_connect(new Gtk::Button(_("Remove Selected")), clicked => \&list_remove, $list_other), ), - 0, gtkset_sensitive(my $check_what_other_versions = new Gtk::CheckButton(_("Use Incremental Backups (do not replace old backups)") ), 0), + 0, my $check_what_other_versions = new Gtk::CheckButton(_("Use Incremental Backups (do not replace old backups)")), ), ); check_list([$check_what_other_versions, \$backup_other_versions]); @@ -4652,6 +4686,14 @@ sub interactive_mode { $interactive = 1; + eval { require my_gtk; }; + if ($@ ne '') { + die "Can't load my_gtk...\n"; + } else { + my_gtk->import(qw(:helpers :wrappers)); + } + my $in = 'interactive'->vnew('', 'default'); + my $box; $my_win = my_gtk->new('drakbackup'); $window1 = $my_win->{window};