]> oss.titaniummirror.com Git - ovzbpc.git/commitdiff
Code has now been tested for restore operation. A VE can restore to itself,
authorsmckown <smckown@986fd584-583e-0410-b54d-b9fe63dff8e5>
Fri, 11 Jan 2008 00:46:58 +0000 (00:46 +0000)
committersmckown <smckown@986fd584-583e-0410-b54d-b9fe63dff8e5>
Fri, 11 Jan 2008 00:46:58 +0000 (00:46 +0000)
another VE or a non-VE server.  Also, remove the unneeded runServer_test sub.

BackupPC_ovz

index 2e0db7cb827824dccc80cd21d64269c96f915703..5b7d010dd19e7b9572c3635b5d7e369bef7ed433 100755 (executable)
@@ -6,7 +6,6 @@
 # with ovz awareness to improve backup and restore efficiency and features.
 
 # FIXME: signal handling to clean up mount point and snapshot on termination
-# FIXME: saveConfigs and restoreConfigs aren't being used yet
 
 use strict;
 use Socket;
@@ -353,6 +352,8 @@ sub saveConfigs($)
   }
 }
 
+# Because of the complexities involved with restoring VE configuartions and
+# knowing when and how to do so, this feature is not currently implemented.
 sub restoreConfigs($)
 {
   my ($ve) = @_;
@@ -421,12 +422,12 @@ sub runClient($)
   die "HN needs a VEID argument" if (!defined($veid));
   die "HN: no command to execute after VEID" if ($#ARGV < 0);
 
-  # Find $host in the list of VEs
+  # We (the HN where this code is running) must be hosting the requested VE.
   my $ve = localVe($veid);
   die "VE $veid not found on this HN" if (!defined($ve));
   #printVeEntry($ve);
 
-  if (! $restore) {
+  if (!$restore) {
     cmdSystemOrEval("vzctl stop $veid >/dev/null 2>&1") if ($ve->{'running'});
     makeSnapshot($ve);
     cmdSystemOrEval("vzctl start $veid >/dev/null 2>&1") if ($ve->{'running'});
@@ -445,7 +446,7 @@ sub runClient($)
     #print "HN: cmd |$cmd|\n";
     $? = 0;
     cmdSystemOrEval($cmd);
-    my $ret = $?; # FIXME
+    my $ret = $?; # FIXME - modify cmdSystemOrEval to get a return value.
 
     # Remove snapshot, we're done
     delSnapshot($ve);
@@ -468,66 +469,6 @@ sub runServer($)
 {
   my ($restore) = @_;
 
-  # Build the beginning remote command
-  my $remoteCmd = "/usr/bin/".basename($0);
-  #print "Remote command is $remoteCmd\n";
-
-  my $host = shift(@ARGV);
-  die "Hostname argument required" if (!defined($host));
-  die "No command to execute after hostname" if ($#ARGV < 0);
-
-  # Find $host in the list of VEs
-  loadVeList();
-  my $ve = getVeByHostname($host);
-  die "VE $host not found" if (!defined($ve));
-  #printVeEntry($ve);
-
-  # The command line is bisected by the next occurrence of $host.  Everything
-  # before is the ssh command (sans what to run on the VE) and everything
-  # after is the xfer command to run on the VE.
-  my @sshCmd;
-  my @xferCmd;
-  my $foundHost = 0;
-  foreach my $arg (@ARGV) {
-    if ($arg eq $host) {
-      $foundHost = 1;
-    } else {
-      if ($foundHost) {
-       push(@xferCmd, $arg);
-      } else {
-       push(@sshCmd, $arg);
-      }
-    }
-  }
-  die "No ssh command found" if ($#sshCmd < 0);
-  die "No xfer command found" if ($#xferCmd < 0);
-  #print "ssh command: |".join(' ', @sshCmd)."|\n";
-  #print "xfer command: |".join(' ', @xferCmd)."|\n";
-
-  # Create command line to initiate the remote side of the backup.  The
-  # remote side runs on the VE's HN and is given the VE's VEID.
-  my $cmd = join(' ', @sshCmd)." ".$ve->{'HN'}." $remoteCmd ".
-    ($restore ? "restore " : "").$ve->{'VEID'}." ".join(' ', @xferCmd);
-  #print "remote command: |$cmd|\n";
-
-  ## Search and replace 
-  #foreach my $key (keys %{$velist[0]}) {
-  #    my $val = $ve->{$key};
-  #    $cmd =~ s/\@$key\@/$val/g if (defined($val));
-  #}
-
-  cmdExecOrEval($cmd);
-}
-
-# A hard-coded test; didn't seem to help
-sub runServer_test($)
-{
-  my ($restore) = @_;
-
-  # Build the beginning remote command
-  my $remoteCmd = "/usr/bin/".basename($0);
-  #print "Remote command is $remoteCmd\n";
-
   my $host = shift(@ARGV);
   die "Hostname argument required" if (!defined($host));
   die "No command to execute after hostname" if ($#ARGV < 0);
@@ -535,12 +476,12 @@ sub runServer_test($)
   # Find $host in the list of VEs
   loadVeList();
   my $ve = getVeByHostname($host);
-  die "VE $host not found" if (!defined($ve));
+  die "$host is not a VE or list of HNs in $0 is wrong" if (!defined($ve));
   #printVeEntry($ve);
 
-  # The command line is bisected by the next occurrence of $host.  Everything
-  # before is the ssh command (sans what to run on the VE) and everything
-  # after is the xfer command to run on the VE.
+  # The client command is bisected by the next occurrence of $host. Everything
+  # before is the ssh command to reach the client and everything after is the
+  # xfer command sent to the client via ssh.
   my @sshCmd;
   my @xferCmd;
   my $foundHost = 0;
@@ -560,18 +501,13 @@ sub runServer_test($)
   #print "ssh command: |".join(' ', @sshCmd)."|\n";
   #print "xfer command: |".join(' ', @xferCmd)."|\n";
 
-  # Create command line to initiate the remote side of the backup.  The
-  # remote side runs on the VE's HN and is given the VE's VEID.
-  my $cmd = join(' ', @sshCmd)." pe18002.titaniummirror.com $remoteCmd ".
-    ($restore ? "restore " : "")."151 ".join(' ', @xferCmd);
+  # Create the command line to initiate the client side of the backup.  We
+  # contact the HN hosting the VE and run an invocation of this script there
+  # to perform the required operations for VE backup or restore.
+  my $cmd;
+  $cmd = join(' ', @sshCmd)." ".$ve->{'HN'}." /usr/bin/".basename($0)." ".
+      ($restore ? "restore " : "").$ve->{'VEID'}." ".join(' ', @xferCmd);
   #print "remote command: |$cmd|\n";
-
-  ## Search and replace 
-  #foreach my $key (keys %{$velist[0]}) {
-  #    my $val = $ve->{$key};
-  #    $cmd =~ s/\@$key\@/$val/g if (defined($val));
-  #}
-
   cmdExecOrEval($cmd);
 }