1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2026-06-20 01:17:49 +02:00

Added diff to commands.

This commit is contained in:
David Steele
2013-12-15 18:18:54 -05:00
parent 31fca50eae
commit 1d21f4f9fa
2 changed files with 26 additions and 12 deletions
+6 -5
View File
@@ -1,12 +1,13 @@
[command]
#compress=pigz --rsyncable --best --stdout %file% # Ubuntu Linux
compress=gzip --stdout %file%
decompress=gzip -dc %file%
compress=/usr/bin/gzip --stdout %file%
decompress=/usr/bin/gzip -dc %file%
#checksum=sha1sum %file% | awk '{print \$1}' # Ubuntu Linux
checksum=shasum %file% | awk '{print $1}'
copy=cp %source% %destination%
checksum=/usr/bin/shasum %file% | awk '{print $1}'
copy=/bin/cp %source% %destination%
manifest=/opt/local/bin/gfind %path% -printf '%P\t%y\t%u\t%g\t%m\t%T@\t%i\t%s\t%l\n'
tablespace_map=psql --port=6001 -c 'copy (select oid, spcname from pg_tablespace) to stdout' postgres
tablespace_map=/Library/PostgreSQL/9.3/bin/psql --port=6001 -c 'copy (select oid, spcname from pg_tablespace) to stdout' postgres
diff=/bin/bash -c '/usr/bin/diff -q %file1% %file2%'
[common]
backup_path=/Users/dsteele/test/backup
+20 -7
View File
@@ -282,7 +282,6 @@ sub backup_manifest_build
die &log(ERROR, "Unrecognized file type $cType for file $strName");
}
# my %oManifest = data_hash_build("name\ttype\tuser\tgroup\tpermission\tmodification_time\tinode\tsize\tlink_destination\n" .
${$oBackupManifestRef}{"${strSection}"}{"$strName"}{user} = $oManifestHash{name}{"${strName}"}{user};
${$oBackupManifestRef}{"${strSection}"}{"$strName"}{group} = $oManifestHash{name}{"${strName}"}{group};
${$oBackupManifestRef}{"${strSection}"}{"$strName"}{permission} = $oManifestHash{name}{"${strName}"}{permission};
@@ -327,6 +326,7 @@ sub backup
my $strCommandCompress = shift;
my $strCommandDecompress = shift;
my $strCommandCopy = shift;
my $strCommandDiff = shift;
my $strClusterDataPath = shift;
my $strBackupTmpPath = shift;
my $oBackupManifestRef = shift;
@@ -438,7 +438,20 @@ sub backup
# Check if the file already exists
if (-e $strBackupDestinationFile)
{
$strCommand = "/bin/bash -c '/usr/bin/diff -q <(/usr/bin/gzip -dc ${strBackupDestinationFile}) <(/usr/bin/gzip -dc ${strBackupDestinationTmpFile})'";
$strCommand = $strCommandDiff;
if ($bNoCompression)
{
$strCommand =~ s/\%file1\%/${strBackupDestinationFile}/g;
$strCommand =~ s/\%file2\%/${strBackupDestinationTmpFile}/g;
}
else
{
$strCommand =~ s/\%file1\%/ \<\(${strCommandDecompress}\)/g;
$strCommand =~ s/\%file\%/${strBackupDestinationFile}/g;
$strCommand =~ s/\%file2\%/ \<\(${strCommandDecompress}\)/g;
$strCommand =~ s/\%file\%/${strBackupDestinationTmpFile}/g;
}
system($strCommand);# or die "unable to execute $strCommand";
@@ -454,7 +467,7 @@ sub backup
}
else
{
die "unable to run diff command"
die "unable to run diff command: $strCommand"
}
}
else
@@ -465,9 +478,7 @@ sub backup
# Write the hash into the backup manifest
${$oBackupManifestRef}{"${strSection}"}{"$strFile"}{checksum} = $strHash;
# Calculate the checksum
# $strCommand =
${$oBackupManifestRef}{checksum}{"${strHash}-${iSize}"}{"$strFile"}{section} = $strSection;
}
}
}
@@ -494,6 +505,7 @@ my $strCommandChecksum = config_load(\%oConfig, "command", "checksum", !$bNoChec
my $strCommandCompress = config_load(\%oConfig, "command", "compress", !$bNoCompression);
my $strCommandDecompress = config_load(\%oConfig, "command", "decompress", !$bNoCompression);
my $strCommandCopy = config_load(\%oConfig, "command", "copy", $bNoCompression);
my $strCommandDiff = config_load(\%oConfig, "command", "diff");
####################################################################################################################################
# ARCHIVE-PUSH Command
@@ -642,7 +654,8 @@ if ($strOperation eq "backup")
# !!! do it
# Perform the backup
backup($strCommandChecksum, $strCommandCompress, $strCommandDecompress, $strCommandCopy, $strClusterDataPath, $strBackupTmpPath, \%oBackupManifest);
backup($strCommandChecksum, $strCommandCompress, $strCommandDecompress, $strCommandCopy, $strCommandDiff,
$strClusterDataPath, $strBackupTmpPath, \%oBackupManifest);
# Save the backup conf file
backup_manifest_save($strBackupConfFile, \%oBackupManifest);