You've already forked pgbackrest
							
							
				mirror of
				https://github.com/pgbackrest/pgbackrest.git
				synced 2025-10-30 23:37:45 +02:00 
			
		
		
		
	copy() works through multiple runs an multiple remotes.
This commit is contained in:
		| @@ -847,7 +847,7 @@ sub copy | ||||
|         $self->{oRemote}->binary_xfer($hIn, $hOut, $strRemote); | ||||
| #        print "binary xfer stop\n"; | ||||
|  | ||||
|         if ($strRemote eq 'out') | ||||
|         if ($strSourcePathType ne PIPE_STDIN && $strDestinationPathType ne PIPE_STDOUT) | ||||
|         { | ||||
|             $self->{oRemote}->output_read(false, $strErrorPrefix); | ||||
|         } | ||||
|   | ||||
| @@ -228,13 +228,15 @@ sub read_line | ||||
|     my $strLine; | ||||
|     my $strChar; | ||||
|     my $iByteIn; | ||||
|      | ||||
|  | ||||
|     while (1) | ||||
|     { | ||||
|         $iByteIn = sysread($hIn, $strChar, 1); | ||||
|          | ||||
|         if (!defined($iByteIn) || $iByteIn != 1) | ||||
|         { | ||||
|             $self->wait_pid(); | ||||
|  | ||||
|             if (defined($bError) and !$bError) | ||||
|             { | ||||
|                 return undef; | ||||
| @@ -254,6 +256,35 @@ sub read_line | ||||
|     return $strLine; | ||||
| } | ||||
|  | ||||
| #################################################################################################################################### | ||||
| # WAIT_PID | ||||
| #################################################################################################################################### | ||||
| sub wait_pid | ||||
| { | ||||
|     my $self = shift; | ||||
|  | ||||
|     if (defined($self->{pId}) && waitpid($self->{pId}, WNOHANG) != 0) | ||||
|     { | ||||
|         my $strError = "no error on stderr"; | ||||
|          | ||||
|         if (!defined($self->{hErr})) | ||||
|         { | ||||
|             $strError = "no error captured because stderr is already closed"; | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             $strError = $self->pipe_to_string($self->{hErr}); | ||||
|         } | ||||
|  | ||||
|         $self->{pId} = undef; | ||||
|         $self->{hIn} = undef; | ||||
|         $self->{hOut} = undef; | ||||
|         $self->{hErr} = undef; | ||||
|          | ||||
|         confess &log(ERROR, "remote process terminated: ${strError}"); | ||||
|     } | ||||
| } | ||||
|  | ||||
| #################################################################################################################################### | ||||
| # BINARY_XFER | ||||
| # | ||||
| @@ -275,6 +306,11 @@ sub binary_xfer | ||||
|     my $iBlockOut; | ||||
|     my $strBlockHeader; | ||||
|     my $strBlock; | ||||
|      | ||||
|     if (!defined($hIn) || !defined($hOut)) | ||||
|     { | ||||
|         confess &log(ASSERT, "hIn or hOut is not defined"); | ||||
|     } | ||||
|  | ||||
|     while (1) | ||||
|     { | ||||
| @@ -371,28 +407,6 @@ sub output_read | ||||
|     my $iErrorCode; | ||||
|     my $strError; | ||||
|  | ||||
|     if (waitpid($self->{pId}, WNOHANG) != 0) | ||||
|     { | ||||
|         print "process exited\n"; | ||||
|          | ||||
|         my $strError = $self->pipe_to_string($self->{hErr}); | ||||
|          | ||||
|         if (defined($strError)) | ||||
|         { | ||||
|             $bError = true; | ||||
|             $strOutput = $strError; | ||||
|         } | ||||
|      | ||||
|         # Capture any errors | ||||
|         if ($bError) | ||||
|         { | ||||
| #            print "error: " . $strOutput->message(); | ||||
|              | ||||
|             confess &log(ERROR, (defined($strErrorPrefix) ? "${strErrorPrefix}" : "") . | ||||
|                                 (defined($strOutput) ? ": ${strOutput}" : "")); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     # print "error read wait\n"; | ||||
|     #  | ||||
|     # if (!eof($self->{hErr})) | ||||
| @@ -433,6 +447,8 @@ sub output_read | ||||
|                             (defined($strOutput) ? ": ${strOutput}" : ""), $iErrorCode); | ||||
|     } | ||||
|      | ||||
|     $self->wait_pid(); | ||||
|      | ||||
|     if ($bOutputRequired && !defined($strOutput)) | ||||
|     { | ||||
|         my $strError = $self->pipe_to_string($self->{hErr}); | ||||
|   | ||||
| @@ -804,24 +804,33 @@ sub BackRestFileTest | ||||
|                 # Loop through destination compression | ||||
|                 for (my $bDestinationCompressed = 0; $bDestinationCompressed <= 0; $bDestinationCompressed++) | ||||
|                 { | ||||
|                     my $strRemote = $bBackupRemote ? 'backup' : $bDbRemote ? 'db' : undef; | ||||
|          | ||||
|                     # $oRemote = BackRest::Remote->new | ||||
|                     # ( | ||||
|                     #     strHost => $strHost, | ||||
|                     #     strUser => $strUser, | ||||
|                     #     strCommand => $strCommand, | ||||
|                     # ); | ||||
|          | ||||
|                     my $oFile = BackRest::File->new | ||||
|                     ( | ||||
|                         strStanza => "db", | ||||
|                         bCompress => $bDestinationCompressed, | ||||
|                         strBackupClusterPath => undef, | ||||
|                         strBackupPath => ${strTestPath}, | ||||
|                         strRemote => $bBackupRemote ? 'backup' : $bDbRemote ? 'db' : undef, | ||||
|                         strRemote => $strRemote, | ||||
|                         oRemote => $bBackupRemote || $bDbRemote ? $oRemote : undef | ||||
|                     ); | ||||
|  | ||||
|                     for (my $bSourceCompressed = 0; $bSourceCompressed <= 0; $bSourceCompressed++) | ||||
|                     { | ||||
|                         for (my $bSourcePathType = 0; $bSourcePathType <= 0; $bSourcePathType++) | ||||
|                         for (my $bSourcePathType = 0; $bSourcePathType <= 1; $bSourcePathType++) | ||||
|                         { | ||||
|                             my $strSourcePathType = $bSourcePathType ? PATH_DB_ABSOLUTE : PATH_BACKUP_ABSOLUTE; | ||||
|                             my $strSourcePath = $bSourcePathType ? "db" : "backup"; | ||||
|  | ||||
|                             for (my $bDestinationPathType = 1; $bDestinationPathType <= 1; $bDestinationPathType++) | ||||
|                             for (my $bDestinationPathType = 0; $bDestinationPathType <= 1; $bDestinationPathType++) | ||||
|                             { | ||||
|                                 my $strDestinationPathType = $bDestinationPathType ? PATH_DB_ABSOLUTE : PATH_BACKUP_ABSOLUTE; | ||||
|                                 my $strDestinationPath = $bDestinationPathType ? "db" : "backup"; | ||||
| @@ -829,8 +838,10 @@ sub BackRestFileTest | ||||
|                                 $iRun++; | ||||
|  | ||||
|                                 &log(INFO, "run ${iRun} - " . | ||||
|                                            "srcpth ${strSourcePath}, bkprmt $bBackupRemote, srccmp $bSourceCompressed, " . | ||||
|                                            "dstpth ${strDestinationPath}, dbrmt $bDbRemote, dstcmp $bDestinationCompressed"); | ||||
|                                            "srcpth " . (defined($strRemote) && $strRemote eq $strSourcePath ? "remote" : "local") . | ||||
|                                                ":${strSourcePath}, srccmp $bSourceCompressed, " . | ||||
|                                            "dstpth " . (defined($strRemote) && $strRemote eq $strDestinationPath ? "remote" : "local") . | ||||
|                                                ":${strDestinationPath}, dstcmp $bDestinationCompressed"); | ||||
|  | ||||
|                                 # Drop the old test directory and create a new one | ||||
|                                 system("rm -rf test"); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user