/[BackupPC]/trunk/bin/BackupPC_recover_from_increments
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/bin/BackupPC_recover_from_increments

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 345 by dpavlin, Tue Mar 7 10:48:28 2006 UTC revision 352 by dpavlin, Wed Apr 26 11:10:48 2006 UTC
# Line 27  use lib "/data/backuppc/lib"; Line 27  use lib "/data/backuppc/lib";
27  use BackupPC::Lib;  use BackupPC::Lib;
28    
29  my $host = 'restore';  my $host = 'restore';
30    my $share = '/etc';
31    
32  # connect to BackupPC_server  # connect to BackupPC_server
33    
# Line 53  die "host '$host' is not found, please a Line 54  die "host '$host' is not found, please a
54    
55  # create restore host configuration  # create restore host configuration
56    
57  my $restore_path = "$Conf{InstallDir}/$Conf{GzipTempDir}/${host}-restore.tar.gz";  my $restore_path = "$Conf{InstallDir}/$Conf{GzipTempDir}/restore.tar.gz";
58    
59  my $conf_restore = <<'_END_OF_CONF_';  my $conf_restore = <<'_END_OF_CONF_';
60    
61  $Conf{XferMethod} = 'tar';  $Conf{XferMethod} = 'tar';
62    $Conf{TarShareName} = '__share__';
63    
64  $Conf{TarFullArgs} = 'echo "full backups are not supported in restore!" ; exit 1';  $Conf{TarFullArgs} = 'echo "full backups are not supported in restore!" ; exit 1';
65  $Conf{TarIncrArgs} = '';  $Conf{TarIncrArgs} = '';
66    
67  # fake ping when restoring  # disable ping
68  $Conf{PingCmd} = '$pingPath -c 1 localhost',  $Conf{PingCmd} = '';
69    # work-around for Backup aborted because of CorrectHostCheck
70    $Conf{FixedIPNetBiosNameCheck} = 0;
71    $Conf{NmbLookupCmd} = '';
72  $Conf{ClientNameAlias} = 'localhost';  $Conf{ClientNameAlias} = 'localhost';
73    
74  $Conf{TarClientCmd} = 'zcat __restore_path__';  $Conf{TarClientCmd} = 'zcat __restore_path__';
# Line 73  $Conf{TarClientCmd} = 'zcat __restore_pa Line 78  $Conf{TarClientCmd} = 'zcat __restore_pa
78  _END_OF_CONF_  _END_OF_CONF_
79    
80  $conf_restore =~ s/__restore_path__/$restore_path/gs;  $conf_restore =~ s/__restore_path__/$restore_path/gs;
81    $conf_restore =~ s/__share__/$share/gs;
82    
83  my $config_file = "$bpc->{TopDir}/conf/${host}.pl";  my $config_file = "$bpc->{TopDir}/conf/${host}.pl";
84    
# Line 85  warn "written config:\n$conf_restore\n"; Line 91  warn "written config:\n$conf_restore\n";
91  sub restore_increment {  sub restore_increment {
92          my $path = shift || die "need path!";          my $path = shift || die "need path!";
93    
94            if ($path !~ m/\.tar\.gz$/i) {
95                    print "skipping $path, not .tar.gz increment\n";
96                    return;
97            }
98    
99          print "working on $path\n";          print "working on $path\n";
100    
101          if (-e $restore_path) {          if (-e $restore_path) {
102                  unlink $restore_path || die "can't remove $restore_path: $!\n";                  unlink $restore_path || die "can't remove $restore_path: $!\n";
103          }          }
104          link $path, $restore_path || die "can't create link $path -> $restore_path: $!\n";          symlink $path, $restore_path || die "can't create link $path -> $restore_path: $!\n";
105    
106          my $user = $host_info->{$host}->{user} || die "can't get user for host $host";          my $user = $host_info->{$host}->{user} || die "can't get user for host $host";
107    
108          $bpc->ServerMesg("log User $user started recovery from increment $path");          $bpc->ServerMesg("log User $user started recovery from increment $path");
109    
110          my $full = 0;          my @backups = $bpc->BackupInfoRead( $host );
111    
112            my $full = 1;
113            foreach my $b (@backups) {
114                    $full = 0 if ($b->{type} eq 'full');
115            }
116    
117          my $r = $bpc->ServerMesg("backup $host $host $user $full");          my $r = $bpc->ServerMesg("backup $host $host $user $full");
118          print "backup --> $r";          print "backup ", $full ? 'full' : 'incremental', " --> $r";
119          die $r if ($r =~ m/^error/);          die $r if ($r =~ m/^error/);
120    
121          # Status_backup_in_progress          # Status_backup_in_progress
# Line 137  foreach my $restore_inc (@ARGV) { Line 154  foreach my $restore_inc (@ARGV) {
154                          restore_increment( $File::Find::name );                          restore_increment( $File::Find::name );
155                  }, follow => 0 }, $restore_inc);                  }, follow => 0 }, $restore_inc);
156    
157          } elsif (-f $restore_inc && $restore_inc =~ m/\.tar\.gz$/i) {          } elsif (-f $restore_inc) {
158                  restore_increment( $restore_inc );                  restore_increment( $restore_inc );
159          } else {          } else {
160                  warn "skipped: $restore_inc, not directory or .tar.gz increment\n";                  warn "skipped: $restore_inc, not file or directory\n";
161          }          }
162    
163  }  }

Legend:
Removed from v.345  
changed lines
  Added in v.352

  ViewVC Help
Powered by ViewVC 1.1.26