summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStew Benedict <stewb@mandriva.org>2004-04-05 22:58:10 +0000
committerStew Benedict <stewb@mandriva.org>2004-04-05 22:58:10 +0000
commit26ba8219de84e314180f8ae780f7f3016177318a (patch)
tree2c17fa68c8c1c36b373bbff3dc945558a25dc8ec
parentb6e55162bb2fec453632e5e7760ab59ecfc0a848 (diff)
downloaddrakx-backup-do-not-use-26ba8219de84e314180f8ae780f7f3016177318a.tar
drakx-backup-do-not-use-26ba8219de84e314180f8ae780f7f3016177318a.tar.gz
drakx-backup-do-not-use-26ba8219de84e314180f8ae780f7f3016177318a.tar.bz2
drakx-backup-do-not-use-26ba8219de84e314180f8ae780f7f3016177318a.tar.xz
drakx-backup-do-not-use-26ba8219de84e314180f8ae780f7f3016177318a.zip
Remove config-info (new home to be man page).
Use ugtk2 cursor wait/normal (share the wheel). Combine/rework restore code.
-rwxr-xr-xperl-install/standalone/drakbackup269
1 files changed, 75 insertions, 194 deletions
diff --git a/perl-install/standalone/drakbackup b/perl-install/standalone/drakbackup
index 379b10cb9..c473c61e6 100755
--- a/perl-install/standalone/drakbackup
+++ b/perl-install/standalone/drakbackup
@@ -140,11 +140,9 @@ $cfg_file = $cfg_dir . "drakbackup.conf";
my $backup_key = $user_home . "/.ssh/identity-drakbackup";
foreach (@ARGV) {
-
/--default/ and backend_mode();
/--daemon/ and daemon_mode();
/--show-conf/ and show_conf();
- /--config-info/ and explain_conf();
/--cd-info/ and get_cd_info(), exit(0);
/--debug/ and $DEBUG = 1, next;
}
@@ -173,71 +171,6 @@ sub show_conf() {
exit(0);
}
-sub explain_conf() {
- print "\nConfiguration File Options: \n\n";
- print "Configuration file is located in:\n";
- print " Root Mode: /etc/drakxtools/drakbackup/drakbackup.conf.\n";
- print " User Mode: ~/.drakbackup/drakbackup.conf.\n\n";
- print "SYS_FILES Comma separated list of system directories to backup.\n";
- print "HOME_FILES Comma separated list of user home directories to backup.\n";
- print "OTHER_FILES Comma separated list of other files to backup.\n";
- print "PATH_TO_SAVE Default Hard Drive path to create backup files in.\n";
- print " Root Mode: default is /var/lib/drakbackup.\n";
- print " User Mode: default is ~/.drakbackup/backups.\n";
- print "NO_SYS_FILES Don't backup system files.\n";
- print "NO_USER_FILES Don't backup user files.\n";
- print "BACKUPIGNORE Honor .backupignore files in backup directories\n";
- print "OPTION_COMP Compression option (tar.gz, tar.bz2, tar).\n";
- print "NO_BROWSER_CACHE Skip web browser cache.\n";
- print "CDRW Backup media is re-writable CD.\n";
- print "DVDR Backup media is recordable DVD (not fully supported yet).\n";
- print "DVDRW Backup media is recordable DVD+RW.\n";
- print "DVDRAM Backup media is DVDRAM (not fully supported yet).\n";
- print "NET_PROTO Network protocol to use for remote backups: \n";
- print " ftp, rsync, ssh, or webdav.\n";
- print "HOST_NAME Remote backup host.\n";
- print "HOST_PATH Backup storage path or module on remote host.\n";
- print "REMEMBER_PASS Remember password on remote host in config file.\n";
- print "USER_KEYS Ssh keys are already setup for communicating with remote host.\n";
- print "DRAK_KEYS Use special drakbackup generated host keys.\n";
- print " (requires perl-Expect).\n";
- print "USE_EXPECT Use expect to do the whole scp transfer, without keys.\n";
- print " (requires perl-Expect).\n";
- print "LOGIN Remote host login name.\n";
- print "PASSWD Password on remote host (if REMEMBER_PASS is enabled).\n";
- print "DAEMON_MEDIA Daemon mode backup via given media.\n";
- print " (hd, cd, tape, ftp, rsync, ssh, or webdav).\n";
- print "HD_QUOTA Use quota to limit hard drive space used for backups.\n";
- print " (not supported yet).\n";
- print "USE_HD Use Hard Drive for backups (currently all modes use HD also).\n";
- print "MAX_SPACE Maximum Hard Drive Space(MB) to consume for backups. \n";
- print "USE_CD Use CD for backups.\n";
- print "USE_NET Use network for backups (driven by NET_PROTO).\n";
- print "USE_TAPE Use tape for backup.\n";
- print "DEL_HD_FILES Delete local hard drive tar files after backup to other media.\n";
- print "TAPE_NOREWIND Use non-rewinding tape device.\n";
- print "CD_TIME Length of CD media (not currently utilized).\n";
- print "DAEMON_TIME_SPACE Interval between daemon backup runs (hourly, daily, weekly)..\n";
- print "CD_WITH_INSTALL_BOOT Build a bootable restore CD (currently not utilized).\n";
- print "CD_DEVICE Cdrecord style CD device name (ie: 1,3,0).\n";
- print "USER_MAIL User to send backup results to via email.\n";
- print "SEND_MAIL Do send backup results via email.\n";
- print "TAPE_DEVICE Device to use for tape backup (ie: /dev/st0).\n";
- print "MEDIA_ERASE Erase media before new backup (applies to tape, CD).\n";
- print "MEDIA_EJECT Eject media after backup completes.\n";
- print "MULTI_SESSION Allow muliple sessions to be written to CD media.\n";
- print "SYS_INCREMENTAL_BACKUPS Do incremental or differential backups of system files.\n";
- print "USER_INCREMENTAL_BACKUPS Do incremental or differential backups of user files.\n";
- print "OTHER_INCREMENTAL_BACKUPS Do incremental or differential backups if other files.\n";
- print "SYS_DIFFERENTIAL_BACKUPS Do differential backups of system files.\n";
- print "USER_DIFFERENTIAL_BACKUPS Do differential backups of user files.\n";
- print "OTHER_DIFFERENTIAL_BACKUPS Do differential backups if other files.\n";
- print "NO_CRITICAL_SYS Do not backup critical system files:\n";
- print " passwd, fstab, group, mtab\n";
- print "CRITICAL_SYS Do backup above system files.\n";
- exit(0);
-}
-
sub backend_mode() {
build_backup_files();
exit(0);
@@ -685,10 +618,10 @@ sub do_expect {
if (!(-e $backup_key) && $mode eq "sendkey") {
$in->ask_warn(N("Information"), N("This may take a moment to generate the keys."));
- cursor_wait();
+ gtkset_mousecursor_wait();
#- not using a passphrase for the moment
system("ssh-keygen -P '' -t dsa -f $backup_key");
- cursor_norm();
+ gtkset_mousecursor_normal();
}
my $exp = Expect->spawn($exp_command) or $in->ask_warn(N("Error"), N("Cannot spawn %s.", $exp_command));
@@ -838,10 +771,10 @@ sub erase_cdrw() {
#- we can only hit this via interactive
$interactive = 0;
$in->ask_warn(N("Information"), N("This may take a moment to erase the media."));
- cursor_wait();
+ gtkset_mousecursor_wait();
my $command = "cdrecord dev=$conf{CD_DEVICE} -blank=fast";
spawn_progress($command, "Erasing CDRW...");
- cursor_norm();
+ gtkset_mousecursor_normal();
$interactive = 1;
}
@@ -906,13 +839,13 @@ sub build_cd() {
sub get_tape_label {
my ($device) = @_;
- cursor_wait();
+ gtkset_mousecursor_wait();
system("mt -f $device rewind");
system("tar -C $cfg_dir -xf $device");
my @volname = cat_("$cfg_dir/drakbackup.label");
unlink("$cfg_dir/drakbackup.label");
$vol_name = $volname[0];
- cursor_norm();
+ gtkset_mousecursor_normal();
$vol_name;
}
@@ -1008,7 +941,7 @@ sub build_backup_files() {
#- flush this so if the user does 2 runs in a row we don't try to send the same files
@file_list_to_send_by_ftp = ();
- $interactive and cursor_wait();
+ $interactive and gtkset_mousecursor_wait();
read_conf_file();
$the_time = the_time();
$conf{SEND_MAIL} and complete_results();
@@ -1024,7 +957,7 @@ sub build_backup_files() {
if ($used_space) {
my $msg = N("Backup quota exceeded!\n%d MB used vs %d MB allocated.", $used_space, $conf{MAX_SPACE});
show_warning("f", $msg);
- $interactive and cursor_norm();
+ $interactive and gtkset_mousecursor_normal();
$results .= $msg;
$interactive and show_status();
results_to_logfile();
@@ -1158,7 +1091,7 @@ sub build_backup_files() {
if (!$filecount) {
my $msg = N("No changes to backup!");
show_warning("w", $msg);
- $interactive and cursor_norm();
+ $interactive and gtkset_mousecursor_normal();
$interactive and interactive_mode();
results_to_logfile();
return 1;
@@ -1261,7 +1194,7 @@ sub build_backup_files() {
system("rm $conf{PATH_TO_SAVE}/list*$the_time.txt");
}
- $interactive and cursor_norm();
+ $interactive and gtkset_mousecursor_normal();
$interactive and show_status();
}
@@ -1384,18 +1317,6 @@ sub check_pkg_needs() {
}
}
-sub cursor_wait() {
- # turn the cursor to a watch
- $window1->window->set_cursor(new Gtk2::Gdk::Cursor("GDK_WATCH"));
- gtkflush();
-}
-
-sub cursor_norm() {
- # restore normal cursor
- $window1->window->set_cursor(new Gtk2::Gdk::Cursor("GDK_LEFT_PTR"));
- gtkflush();
-}
-
sub show_status() {
my $text = new Gtk2::TextView;
destroy_widget();
@@ -3426,7 +3347,7 @@ sub catalog_restore {
$cat_entry = '';
return;
}
- cursor_wait();
+ gtkset_mousecursor_wait();
@restore_files = ();
$lmodel->clear;
foreach my $filename (glob("$conf{PATH_TO_SAVE}/list*$cat_entry.txt")) {
@@ -3437,7 +3358,7 @@ sub catalog_restore {
$lmodel->append_set(undef, $s);
}
}
- cursor_norm();
+ gtkset_mousecursor_normal();
my @full_cat_entry = grep { /^$cat_entry/ } @catalog;
$cat_entry = $full_cat_entry[0];
});
@@ -3630,28 +3551,38 @@ sub restore_catalog_entry {
}
+sub untar {
+ my ($cmd, $msg, $tarfile, $restorefile) = @_;
+ my $message = "Untarring from \n$tarfile \nto $restore_path.";
+ $message = "Untarring \n$restorefile from \n$tarfile \nto $restore_path." if $msg eq "files";
+ my $untar_cmd = set_tar($untar_prefix, $tarfile);
+ my $command = "$untar_cmd $cmd";
+ spawn_progress($command, $message);
+}
+
+sub no_tarfile {
+ my ($tarfile) = @_;
+ if (!-e "$cfg_dir/restores/$tarfile") {
+ show_warning("f", N("%s not retrieved...", $tarfile));
+ return 1;
+ }
+}
+
sub restore_hd_or_cd {
my ($cat_entry, $tarfile_dir, @restore_files) = @_;
my $indv_files = @restore_files;
- my $command;
-
my $wild_card = catalog_to_wildcard($cat_entry);
if ($indv_files == 0) {
#- full catalog specified
- foreach (wildcard_to_tarfile($wild_card)) {
- my $untar_cmd = set_tar($untar_prefix, $_);
- $command = "$untar_cmd $tarfile_dir/$_";
- spawn_progress($command, "Untarring from \n$_ \nto $restore_path.");
+ foreach (wildcard_to_tarfile($wild_card)) {
+ untar("$tarfile_dir/$_", "all", $_, undef);
}
} else {
#- individual files - pull from appropriate catalog
foreach (@restore_files) {
- my $tarfile = file_to_tarfile($_, $wild_card);
- my $untar_cmd = set_tar($untar_prefix, $tarfile);
- $_ = substr($_, 1);
- $command = "$untar_cmd $tarfile_dir/$tarfile $_";
- spawn_progress($command, "Untarring \n$_ from \n$tarfile \nto $restore_path.");
+ my ($restorefile, $tarfile) = file_to_tarfile($_, $wild_card);
+ untar("$tarfile_dir/$tarfile $restorefile", "files", $tarfile, $restorefile);
}
}
return 0;
@@ -3660,50 +3591,23 @@ sub restore_hd_or_cd {
sub restore_tape {
my ($cat_entry, $dev_path, @restore_files) = @_;
my $indv_files = @restore_files;
- my $command;
-
my $wild_card = catalog_to_wildcard($cat_entry);
$dev_path =~ s|/st|/nst|;
if ($indv_files == 0) {
#- full catalog specified
foreach (wildcard_to_tarfile($wild_card)) {
- my $offset = find_tape_offset($cat_entry);
- $command = "mt -f $dev_path rewind";
- spawn_progress($command, "Rewinding tape on $dev_path.");
- $command = "mt -f $dev_path fsf $offset";
- spawn_progress($command, "Moving forward $offset file records.");
- $command = "tar -C $cfg_dir/restores -xf $dev_path";
- spawn_progress($command, "Untarring from $dev_path to work directory.");
- if (-e "$cfg_dir/restores/$conf{PATH_TO_SAVE}/$_") {
- my $untar_cmd = set_tar($untar_prefix, $_);
- $command = "$untar_cmd $cfg_dir/restores/$conf{PATH_TO_SAVE}/$_";
- spawn_progress($command, "Untarring \n$_ \nto $restore_path.");
- } else {
- return 1;
- }
+ get_file_from_tape($cat_entry, $dev_path);
+ return 1 if no_tarfile("$conf{PATH_TO_SAVE}/$_");
+ untar("$cfg_dir/restores/$conf{PATH_TO_SAVE}/$_", "all", $_, undef);
}
} else {
#- individual files - pull from appropriate catalog
foreach (@restore_files) {
- my $tarfile = file_to_tarfile($_, $wild_card);
- $_ = substr($_, 1);
- if (!-e "$cfg_dir/restores/$tarfile") {
- my $offset = find_tape_offset($cat_entry);
- $command = "mt -f $dev_path rewind";
- spawn_progress($command, "Rewinding tape on $dev_path.");
- $command = "mt -f $dev_path fsf $offset";
- spawn_progress($command, "Moving forward $offset file records.");
- $command = "tar -C cfg_dir/restores -xf $dev_path";
- spawn_progress($command, "Untarring from $dev_path to work directory.");
- }
- if (-e "$cfg_dir/restores/$tarfile") {
- my $untar_cmd = set_tar($untar_prefix, $_);
- $command = "$untar_cmd $cfg_dir/restores/$tarfile $_";
- spawn_progress($command, "Untarring \n$_ from \n$tarfile \nto $restore_path.");
- } else {
- return 1;
- }
+ my ($restorefile, $tarfile) = file_to_tarfile($_, $wild_card);
+ get_file_from_tape($cat_entry, $dev_path) if !-e "$cfg_dir/restores/$tarfile";
+ return 1 if no_tarfile($tarfile);
+ untar("$cfg_dir/restores/$tarfile $restorefile", "files", $tarfile, $restorefile);
}
}
return 0;
@@ -3714,7 +3618,6 @@ sub restore_ftp {
my $ftp;
my ($cat_entry, $hostname, $hostpath, $username, $userpass, @restore_files) = @_;
my $indv_files = @restore_files;
- my $command;
$DEBUG and print "file list to retrieve: $cat_entry\n ";
if ($DEBUG && $interactive) { $ftp = Net::FTP->new($hostname, Debug => 1) or return 1 }
@@ -3729,31 +3632,18 @@ sub restore_ftp {
#- full catalog specified
foreach (wildcard_to_tarfile($wild_card)) {
$ftp->get($_, "$cfg_dir/restores/$_");
- if (-e "$cfg_dir/restores/$_") {
- my $untar_cmd = set_tar($untar_prefix, $_);
- $command = "$untar_cmd $cfg_dir/restores/$_";
- spawn_progress($command, "Untarring \n$_ \nto $restore_path.");
- } else {
- show_warning("f", N("%s not retrieved...", $_));
- return 1;
- }
+ return 1 if no_tarfile($_);
+ untar("$cfg_dir/restores/$_", "all", $_, undef);
}
} else {
#- individual files - pull from appropriate catalog
foreach (@restore_files) {
- my $tarfile = file_to_tarfile($_, $wild_card);
- $_ = substr($_, 1);
+ my ($restorefile, $tarfile) = file_to_tarfile($_, $wild_card);
if (!-e "$cfg_dir/restores/$tarfile") {
$ftp->get($tarfile, "$cfg_dir/restores/$tarfile");
}
- if (-e "$cfg_dir/restores/$tarfile") {
- my $untar_cmd = set_tar($untar_prefix, $tarfile);
- $command = "$untar_cmd $cfg_dir/restores/$tarfile $_";
- spawn_progress($command, "Untarring \n$_ from \n$tarfile \nto $restore_path.");
- } else {
- show_warning("f", N("%s not retrieved...", $tarfile));
- return 1;
- }
+ return 1 if no_tarfile($tarfile);
+ untar("$cfg_dir/restores/$tarfile $restorefile", "files", $tarfile, $restorefile);
}
}
$ftp->quit;
@@ -3763,54 +3653,39 @@ sub restore_ftp {
sub restore_rsync_ssh_webdav {
my ($cat_entry, $hostname, $hostpath, $username, $mode, @restore_files) = @_;
my $indv_files = @restore_files;
- my $command;
my $wild_card = catalog_to_wildcard($cat_entry);
if ($indv_files == 0) {
#- full catalog specified
foreach (wildcard_to_tarfile($wild_card)) {
- if ($mode eq 'ssh') {
- $command = "scp $username\@$hostname:$hostpath/$_ $cfg_dir/restores/";
- } elsif ($mode eq 'rsync') {
- $command = "rsync --password-file=$cfg_dir/rsync.user $username\@$hostname" . "::" . "$hostpath/$_ $cfg_dir/restores/";
- } else {
- $command = "wget http://$hostname/$hostpath/$_ -P $cfg_dir/restores/";
- }
- spawn_progress($command, "Retrieving backup file \n$_ \nvia $mode.");
- if (-e "$cfg_dir/restores/$_") {
- my $untar_cmd = set_tar($untar_prefix, $_);
- $command = "$untar_cmd $cfg_dir/restores/$_";
- spawn_progress($command, "Untarring \n$_ \nto $restore_path.");
- } else {
- return 1;
- }
+ get_file_from_net($mode, $_, $hostname, $hostpath, $username);
+ return 1 if no_tarfile($_);
+ untar("$cfg_dir/restores/$_", "all", $_, undef);
}
} else {
#- individual files - pull from appropriate catalog
foreach (@restore_files) {
- my $tarfile = file_to_tarfile($_, $wild_card);
- $_ = substr($_, 1);
- if (!-e "$cfg_dir/restores/$tarfile") {
- if ($mode eq 'ssh') {
- $command = "scp $username\@$hostname:$hostpath/$tarfile $cfg_dir/restores/";
- } elsif ($mode eq 'rsync') {
- $command = "rsync --password-file=$cfg_dir/rsync.user $username\@$hostname" . "::" . "$hostpath/$tarfile $cfg_dir/restores/";
- } else {
- $command = "wget http://$hostname/$hostpath/$tarfile -P $cfg_dir/restores/";
- }
- spawn_progress($command, "Retrieving backup file \n$tarfile \nvia $mode.");
- }
- if (-e "$cfg_dir/restores/$tarfile") {
- my $untar_cmd = set_tar($untar_prefix, $tarfile);
- $command = "$untar_cmd $cfg_dir/restores/$tarfile $_";
- spawn_progress($command, "Untarring \n$_ from \n$tarfile \nto $restore_path.");
- } else {
- return 1;
- }
+ my ($restorefile, $tarfile) = file_to_tarfile($_, $wild_card);
+ get_file_from_net($mode, $tarfile, $hostname, $hostpath, $username) if !-e "$cfg_dir/restores/$tarfile";
+ return 1 if no_tarfile($tarfile);
+ untar("$cfg_dir/restores/$tarfile $restorefile", "files", $tarfile, $restorefile);
}
}
return 0;
}
+sub get_file_from_net {
+ my ($mode, $tarfile, $hostname, $hostpath, $username) = @_;
+ my $command;
+ if ($mode eq 'ssh') {
+ $command = "scp $username\@$hostname:$hostpath/$tarfile $cfg_dir/restores/";
+ } elsif ($mode eq 'rsync') {
+ $command = "rsync --password-file=$cfg_dir/rsync.user $username\@$hostname" . "::" . "$hostpath/$tarfile $cfg_dir/restores/";
+ } else {
+ $command = "wget http://$hostname/$hostpath/$tarfile -P $cfg_dir/restores/";
+ }
+ spawn_progress($command, "Retrieving backup file \n$tarfile \nvia $mode.");
+}
+
sub catalog_to_wildcard {
my ($cat_entry) = @_;
my @line_data = split(':', $cat_entry);
@@ -3833,10 +3708,11 @@ sub file_to_tarfile {
my ($restore_file, $wildcard) = @_;
my $tarfile = `grep -l $restore_file $conf{PATH_TO_SAVE}/*$wildcard.txt`;
chop $tarfile;
+ $restore_file = substr($restore_file, 1);
$tarfile = basename($tarfile);
$tarfile =~ s/txt/$conf{OPTION_COMP}/;
$tarfile =~ s/list/backup/;
- $tarfile;
+ $restore_file, $tarfile;
}
sub find_tape_offset {
@@ -3859,6 +3735,14 @@ sub find_tape_offset {
}
}
+sub get_file_from_tape {
+ my ($cat_entry, $dev_path) = @_;
+ my $offset = find_tape_offset($cat_entry);
+ spawn_progress("mt -f $dev_path rewind", "Rewinding tape on $dev_path.");
+ spawn_progress("mt -f $dev_path fsf $offset", "Moving forward $offset file records.");
+ spawn_progress("tar -C cfg_dir/restores -xf $dev_path", "Untarring from $dev_path to work directory.");
+}
+
sub restore_box() {
my $retore_box;
@@ -4366,7 +4250,6 @@ sub build_backup_status() {
gtkflush();
}
-
sub build_backup_ftp_status() {
$pbar = new Gtk2::ProgressBar;
$pbar3 = new Gtk2::ProgressBar;
@@ -4561,8 +4444,6 @@ sub interactive_mode() {
$my_win->exit(0);
}
-################################################ HELP & ABOUT ################################################
-
sub adv_help() {
exec("drakhelp --id drakbackup") unless fork();
}