You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-06-23 00:07:44 +02:00
Working on archive-local command.
This commit is contained in:
41
pg_backrest.pl
Normal file → Executable file
41
pg_backrest.pl
Normal file → Executable file
@ -2,16 +2,51 @@
|
|||||||
|
|
||||||
#use Getopt::Long;
|
#use Getopt::Long;
|
||||||
|
|
||||||
|
my $strCommandCompress = "pigz --rsyncable --best --stdout %file%";
|
||||||
|
my $strCommandHash = "sha1sum %file% | awk '{print \$1}'";
|
||||||
|
|
||||||
sub execute
|
sub execute
|
||||||
{
|
{
|
||||||
local($strCommand) = @_;
|
local($strCommand) = @_;
|
||||||
my $strOutput;
|
my $strOutput;
|
||||||
|
|
||||||
print("$strCommand\n");
|
# print("$strCommand\n");
|
||||||
$strOutput = qx($strCommand) or return 0;
|
$strOutput = qx($strCommand) or return 0;
|
||||||
print("$strOutput\n");
|
# print("$strOutput\n");
|
||||||
|
|
||||||
return 1;
|
return($strOutput);
|
||||||
|
}
|
||||||
|
|
||||||
|
sub file_hash_get
|
||||||
|
{
|
||||||
|
local($strFile) = @_;
|
||||||
|
|
||||||
|
my $strCommand = $strCommandHash;
|
||||||
|
$strCommand =~ s/\%file\%/$strFile/g;
|
||||||
|
|
||||||
|
my $strHash = execute($strCommand);
|
||||||
|
$strHash =~ s/^\s+|\s+$//g;
|
||||||
|
|
||||||
|
return($strHash);
|
||||||
|
}
|
||||||
|
|
||||||
|
# Get the command
|
||||||
|
$strCommand = $ARGV[0];
|
||||||
|
|
||||||
|
if ($strCommand eq "archive-local")
|
||||||
|
{
|
||||||
|
my $strSource = $ARGV[1];
|
||||||
|
my $strDestination = $ARGV[2];
|
||||||
|
|
||||||
|
my $strCommand = $strCommandCompress;
|
||||||
|
$strCommand =~ s/\%file\%/$strFile/g;
|
||||||
|
|
||||||
|
my $strHash = file_hash_get($strSource);
|
||||||
|
|
||||||
|
$strCommand !!! construct the rest of the string
|
||||||
|
|
||||||
|
print("$strHash");
|
||||||
|
# execute("$strCommandCompress $strSource >
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user