mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2024-11-24 08:52:38 +02:00
Merge branch 'master' into pgpro-2071
This commit is contained in:
commit
eb15c16967
4
doit.cmd
4
doit.cmd
@ -1 +1,3 @@
|
||||
perl win32build.pl "C:\PgProject\pgwininstall-ee\builddir\distr_X64_10.4.1\postgresql" "C:\PgProject\pgwininstall-ee\builddir\postgresql\postgrespro-enterprise-10.4.1\src"
|
||||
CALL "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall" amd64
|
||||
SET PERL5LIB=.
|
||||
perl gen_probackup_project.pl C:\Shared\Postgresql\myPostgres\11\postgrespro
|
@ -1,10 +1,15 @@
|
||||
# -*-perl-*- hey - emacs - this is a perl file
|
||||
BEGIN{
|
||||
# my $currpath = cwd();
|
||||
|
||||
our $pgsrc;
|
||||
our $currpath;
|
||||
|
||||
BEGIN {
|
||||
# path to the pg_pprobackup dir
|
||||
$currpath = File::Basename::dirname(Cwd::abs_path($0));
|
||||
use Cwd;
|
||||
use File::Basename;
|
||||
|
||||
my $pgsrc="";
|
||||
if (@ARGV==1)
|
||||
if (($#ARGV+1)==1)
|
||||
{
|
||||
$pgsrc = shift @ARGV;
|
||||
if($pgsrc eq "--help"){
|
||||
@ -23,14 +28,13 @@ else
|
||||
chdir($path);
|
||||
chdir("../..");
|
||||
$pgsrc = cwd();
|
||||
$currpath = "contrib/pg_probackup";
|
||||
}
|
||||
|
||||
chdir("$pgsrc/src/tools/msvc");
|
||||
push(@INC, "$pgsrc/src/tools/msvc");
|
||||
chdir("../../..") if (-d "../msvc" && -d "../../../src");
|
||||
|
||||
}
|
||||
|
||||
use Win32;
|
||||
use Carp;
|
||||
use strict;
|
||||
@ -84,22 +88,27 @@ my $vcver = build_pgprobackup($config);
|
||||
my $bconf = $ENV{CONFIG} || "Release";
|
||||
my $msbflags = $ENV{MSBFLAGS} || "";
|
||||
my $buildwhat = $ARGV[1] || "";
|
||||
if (uc($ARGV[0]) eq 'DEBUG')
|
||||
{
|
||||
$bconf = "Debug";
|
||||
}
|
||||
elsif (uc($ARGV[0]) ne "RELEASE")
|
||||
{
|
||||
$buildwhat = $ARGV[0] || "";
|
||||
}
|
||||
|
||||
# if (uc($ARGV[0]) eq 'DEBUG')
|
||||
# {
|
||||
# $bconf = "Debug";
|
||||
# }
|
||||
# elsif (uc($ARGV[0]) ne "RELEASE")
|
||||
# {
|
||||
# $buildwhat = $ARGV[0] || "";
|
||||
# }
|
||||
|
||||
# printf "currpath=$currpath";
|
||||
|
||||
# exit(0);
|
||||
# ... and do it
|
||||
system("msbuild pg_probackup.vcxproj /verbosity:normal $msbflags /p:Configuration=$bconf" );
|
||||
|
||||
|
||||
# report status
|
||||
|
||||
my $status = $? >> 8;
|
||||
printf("Status: $status\n");
|
||||
printf("Output file built in the folder $pgsrc/$bconf/pg_probackup\n");
|
||||
|
||||
exit $status;
|
||||
|
||||
@ -126,10 +135,10 @@ sub build_pgprobackup
|
||||
|
||||
#vvs test
|
||||
my $probackup =
|
||||
$solution->AddProject('pg_probackup', 'exe', 'pg_probackup'); #, 'contrib/pg_probackup'
|
||||
$solution->AddProject("pg_probackup", 'exe', "pg_probackup"); #, 'contrib/pg_probackup'
|
||||
$probackup->AddDefine('FRONTEND');
|
||||
$probackup->AddFiles(
|
||||
'contrib/pg_probackup/src',
|
||||
"$currpath/src",
|
||||
'archive.c',
|
||||
'backup.c',
|
||||
'catalog.c',
|
||||
@ -149,7 +158,7 @@ sub build_pgprobackup
|
||||
'validate.c'
|
||||
);
|
||||
$probackup->AddFiles(
|
||||
'contrib/pg_probackup/src/utils',
|
||||
"$currpath/src/utils",
|
||||
'configuration.c',
|
||||
'json.c',
|
||||
'logger.c',
|
||||
@ -157,32 +166,32 @@ sub build_pgprobackup
|
||||
'pgut.c',
|
||||
'thread.c'
|
||||
);
|
||||
$probackup->AddFile('src/backend/access/transam/xlogreader.c');
|
||||
$probackup->AddFile('src/backend/utils/hash/pg_crc.c');
|
||||
$probackup->AddFile("$pgsrc/src/backend/access/transam/xlogreader.c");
|
||||
$probackup->AddFile("$pgsrc/src/backend/utils/hash/pg_crc.c");
|
||||
$probackup->AddFiles(
|
||||
'src/bin/pg_basebackup',
|
||||
"$pgsrc/src/bin/pg_basebackup",
|
||||
'receivelog.c',
|
||||
'streamutil.c'
|
||||
);
|
||||
|
||||
if (-e 'src/bin/pg_basebackup/walmethods.c')
|
||||
if (-e "$pgsrc/src/bin/pg_basebackup/walmethods.c")
|
||||
{
|
||||
$probackup->AddFile('src/bin/pg_basebackup/walmethods.c');
|
||||
$probackup->AddFile("$pgsrc/src/bin/pg_basebackup/walmethods.c");
|
||||
}
|
||||
|
||||
$probackup->AddFile('src/bin/pg_rewind/datapagemap.c');
|
||||
$probackup->AddFile("$pgsrc/src/bin/pg_rewind/datapagemap.c");
|
||||
|
||||
$probackup->AddFile('src/interfaces/libpq/pthread-win32.c');
|
||||
$probackup->AddFile("$pgsrc/src/interfaces/libpq/pthread-win32.c");
|
||||
|
||||
$probackup->AddIncludeDir('src/bin/pg_basebackup');
|
||||
$probackup->AddIncludeDir('src/bin/pg_rewind');
|
||||
$probackup->AddIncludeDir('src/interfaces/libpq');
|
||||
$probackup->AddIncludeDir('src');
|
||||
$probackup->AddIncludeDir('src/port');
|
||||
$probackup->AddIncludeDir("$pgsrc/src/bin/pg_basebackup");
|
||||
$probackup->AddIncludeDir("$pgsrc/src/bin/pg_rewind");
|
||||
$probackup->AddIncludeDir("$pgsrc/src/interfaces/libpq");
|
||||
$probackup->AddIncludeDir("$pgsrc/src");
|
||||
$probackup->AddIncludeDir("$pgsrc/src/port");
|
||||
|
||||
$probackup->AddIncludeDir('contrib/pg_probackup');
|
||||
$probackup->AddIncludeDir('contrib/pg_probackup/src');
|
||||
$probackup->AddIncludeDir('contrib/pg_probackup/src/utils');
|
||||
$probackup->AddIncludeDir("$currpath");
|
||||
$probackup->AddIncludeDir("$currpath/src");
|
||||
$probackup->AddIncludeDir("$currpath/src/utils");
|
||||
|
||||
$probackup->AddReference($libpq, $libpgfeutils, $libpgcommon, $libpgport);
|
||||
$probackup->AddLibrary('ws2_32.lib');
|
||||
|
@ -1,28 +0,0 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Express 2013 for Windows Desktop
|
||||
VisualStudioVersion = 12.0.31101.0
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "pg_probackup", "pg_probackup.vcxproj", "{4886B21A-D8CA-4A03-BADF-743B24C88327}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Win32 = Debug|Win32
|
||||
Debug|x64 = Debug|x64
|
||||
Release|Win32 = Release|Win32
|
||||
Release|x64 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4886B21A-D8CA-4A03-BADF-743B24C88327}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{4886B21A-D8CA-4A03-BADF-743B24C88327}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{4886B21A-D8CA-4A03-BADF-743B24C88327}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{4886B21A-D8CA-4A03-BADF-743B24C88327}.Debug|x64.Build.0 = Debug|x64
|
||||
{4886B21A-D8CA-4A03-BADF-743B24C88327}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{4886B21A-D8CA-4A03-BADF-743B24C88327}.Release|Win32.Build.0 = Release|Win32
|
||||
{4886B21A-D8CA-4A03-BADF-743B24C88327}.Release|x64.ActiveCfg = Release|x64
|
||||
{4886B21A-D8CA-4A03-BADF-743B24C88327}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
EndGlobal
|
@ -1,215 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{4886B21A-D8CA-4A03-BADF-743B24C88327}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>pg_probackup</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>../;@PGSRC@\include;@PGSRC@\bin\pg_basebackup;@PGSRC@\bin\pg_rewind;@PGSRC@\include\port\win32_msvc;@PGSRC@\interfaces\libpq;@PGSRC@\include\port\win32;@PGSRC@\port;@ADDINCLUDE@;@PGSRC@;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>@PGROOT@\lib;$(LibraryPath)</LibraryPath>
|
||||
<ExcludePath />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>../;@PGSRC@\include;@PGSRC@\bin\pg_basebackup;@PGSRC@\bin\pg_rewind;@PGSRC@\include\port\win32_msvc;@PGSRC@\interfaces\libpq;@PGSRC@\include\port\win32;@PGSRC@\port;@ADDINCLUDE@;@PGSRC@;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>@PGROOT@\lib;$(LibraryPath)</LibraryPath>
|
||||
<ExcludePath />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>../;@PGSRC@\include;@PGSRC@\bin\pg_basebackup;@PGSRC@\bin\pg_rewind;@PGSRC@\include\port\win32_msvc;@PGSRC@\interfaces\libpq;@PGSRC@\include\port\win32;@PGSRC@\port;@ADDINCLUDE@;@PGSRC@;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>@PGROOT@\lib;$(LibraryPath)</LibraryPath>
|
||||
<ExcludePath />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>../;@PGSRC@\include;@PGSRC@\bin\pg_basebackup;@PGSRC@\bin\pg_rewind;@PGSRC@\include\port\win32_msvc;@PGSRC@\interfaces\libpq;@PGSRC@\include\port\win32;@PGSRC@\port;@ADDINCLUDE@;@PGSRC@;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>@PGROOT@\lib;$(LibraryPath)</LibraryPath>
|
||||
<ExcludePath />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>@ADDLIBS32@;libpgfeutils.lib;libpgcommon.lib;libpgport.lib;libpq.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>@ADDLIBS@;libpgfeutils.lib;libpgcommon.lib;libpgport.lib;libpq.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>@ADDLIBS32@;libpgfeutils.lib;libpgcommon.lib;libpgport.lib;libpq.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>@ADDLIBS@;libpgfeutils.lib;libpgcommon.lib;libpgport.lib;libpq.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="@PGSRC@\backend\access\transam\xlogreader.c" />
|
||||
<ClCompile Include="@PGSRC@\backend\utils\hash\pg_crc.c" />
|
||||
<ClCompile Include="@PGSRC@\bin\pg_basebackup\receivelog.c" />
|
||||
<ClCompile Include="@PGSRC@\bin\pg_basebackup\streamutil.c" />
|
||||
<ClCompile Include="@PGSRC@\bin\pg_basebackup\walmethods.c" />
|
||||
<ClCompile Include="@PGSRC@\bin\pg_rewind\datapagemap.c" />
|
||||
<ClCompile Include="@PGSRC@\interfaces\libpq\pthread-win32.c" />
|
||||
<ClCompile Include="..\src\archive.c" />
|
||||
<ClCompile Include="..\src\backup.c" />
|
||||
<ClCompile Include="..\src\catalog.c" />
|
||||
<ClCompile Include="..\src\configure.c" />
|
||||
<ClCompile Include="..\src\data.c" />
|
||||
<ClCompile Include="..\src\delete.c" />
|
||||
<ClCompile Include="..\src\dir.c" />
|
||||
<ClCompile Include="..\src\fetch.c" />
|
||||
<ClCompile Include="..\src\help.c" />
|
||||
<ClCompile Include="..\src\init.c" />
|
||||
<ClCompile Include="..\src\parsexlog.c" />
|
||||
<ClCompile Include="..\src\pg_probackup.c" />
|
||||
<ClCompile Include="..\src\restore.c" />
|
||||
<ClCompile Include="..\src\show.c" />
|
||||
<ClCompile Include="..\src\status.c" />
|
||||
<ClCompile Include="..\src\util.c" />
|
||||
<ClCompile Include="..\src\utils\configuration.c" />
|
||||
<ClCompile Include="..\src\utils\logger.c" />
|
||||
<ClCompile Include="..\src\utils\parray.c" />
|
||||
<ClCompile Include="..\src\utils\pgut.c" />
|
||||
<ClCompile Include="..\src\validate.c" />
|
||||
<ClCompile Include="..\src\utils\json.c" />
|
||||
<ClCompile Include="..\src\utils\thread.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="@PGSRC@\bin\pg_basebackup\receivelog.h" />
|
||||
<ClInclude Include="@PGSRC@\bin\pg_basebackup\streamutil.h" />
|
||||
<ClInclude Include="@PGSRC@\bin\pg_basebackup\walmethods.h" />
|
||||
<ClInclude Include="@PGSRC@\bin\pg_rewind\datapagemap.h" />
|
||||
<ClInclude Include="@PGSRC@\bin\pg_rewind\logging.h" />
|
||||
<ClInclude Include="..\src\pg_probackup.h" />
|
||||
<ClInclude Include="..\src\utils\configuration.h" />
|
||||
<ClInclude Include="..\src\utils\logger.h" />
|
||||
<ClInclude Include="..\src\utils\parray.h" />
|
||||
<ClInclude Include="..\src\utils\pgut.h" />
|
||||
<ClInclude Include="..\src\utils\json.h" />
|
||||
<ClInclude Include="..\src\utils\thread.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,213 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{4886B21A-D8CA-4A03-BADF-743B24C88327}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>pg_probackup</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>../;@PGSRC@\include;@PGSRC@\bin\pg_basebackup;@PGSRC@\bin\pg_rewind;@PGSRC@\include\port\win32_msvc;@PGSRC@\interfaces\libpq;@PGSRC@\include\port\win32;@PGSRC@\port;@ADDINCLUDE@;@PGSRC@;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>@PGROOT@\lib;$(LibraryPath)</LibraryPath>
|
||||
<ExcludePath />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>../;@PGSRC@\include;@PGSRC@\bin\pg_basebackup;@PGSRC@\bin\pg_rewind;@PGSRC@\include\port\win32_msvc;@PGSRC@\interfaces\libpq;@PGSRC@\include\port\win32;@PGSRC@\port;@ADDINCLUDE@;@PGSRC@;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>@PGROOT@\lib;$(LibraryPath)</LibraryPath>
|
||||
<ExcludePath />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>../;@PGSRC@\include;@PGSRC@\bin\pg_basebackup;@PGSRC@\bin\pg_rewind;@PGSRC@\include\port\win32_msvc;@PGSRC@\interfaces\libpq;@PGSRC@\include\port\win32;@PGSRC@\port;@ADDINCLUDE@;@PGSRC@;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>@PGROOT@\lib;$(LibraryPath)</LibraryPath>
|
||||
<ExcludePath />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>../;@PGSRC@\include;@PGSRC@\bin\pg_basebackup;@PGSRC@\bin\pg_rewind;@PGSRC@\include\port\win32_msvc;@PGSRC@\interfaces\libpq;@PGSRC@\include\port\win32;@PGSRC@\port;@ADDINCLUDE@;@PGSRC@;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>@PGROOT@\lib;$(LibraryPath)</LibraryPath>
|
||||
<ExcludePath />
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>@ADDLIBS32@;libpgfeutils.lib;libpgcommon.lib;libpgport.lib;libpq.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>@ADDLIBS@;libpgfeutils.lib;libpgcommon.lib;libpgport.lib;libpq.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>@ADDLIBS32@;libpgfeutils.lib;libpgcommon.lib;libpgport.lib;libpq.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>@ADDLIBS@;libpgfeutils.lib;libpgcommon.lib;libpgport.lib;libpq.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
|
||||
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="@PGSRC@\backend\access\transam\xlogreader.c" />
|
||||
<ClCompile Include="@PGSRC@\backend\utils\hash\pg_crc.c" />
|
||||
<ClCompile Include="@PGSRC@\bin\pg_basebackup\receivelog.c" />
|
||||
<ClCompile Include="@PGSRC@\bin\pg_basebackup\streamutil.c" />
|
||||
<ClCompile Include="@PGSRC@\bin\pg_rewind\datapagemap.c" />
|
||||
<ClCompile Include="@PGSRC@\interfaces\libpq\pthread-win32.c" />
|
||||
<ClCompile Include="..\src\archive.c" />
|
||||
<ClCompile Include="..\src\backup.c" />
|
||||
<ClCompile Include="..\src\catalog.c" />
|
||||
<ClCompile Include="..\src\configure.c" />
|
||||
<ClCompile Include="..\src\data.c" />
|
||||
<ClCompile Include="..\src\delete.c" />
|
||||
<ClCompile Include="..\src\dir.c" />
|
||||
<ClCompile Include="..\src\fetch.c" />
|
||||
<ClCompile Include="..\src\help.c" />
|
||||
<ClCompile Include="..\src\init.c" />
|
||||
<ClCompile Include="..\src\parsexlog.c" />
|
||||
<ClCompile Include="..\src\pg_probackup.c" />
|
||||
<ClCompile Include="..\src\restore.c" />
|
||||
<ClCompile Include="..\src\show.c" />
|
||||
<ClCompile Include="..\src\status.c" />
|
||||
<ClCompile Include="..\src\util.c" />
|
||||
<ClCompile Include="..\src\utils\configuration.c" />
|
||||
<ClCompile Include="..\src\utils\logger.c" />
|
||||
<ClCompile Include="..\src\utils\parray.c" />
|
||||
<ClCompile Include="..\src\utils\pgut.c" />
|
||||
<ClCompile Include="..\src\validate.c" />
|
||||
<ClCompile Include="..\src\utils\json.c" />
|
||||
<ClCompile Include="..\src\utils\thread.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="@PGSRC@\bin\pg_basebackup\receivelog.h" />
|
||||
<ClInclude Include="@PGSRC@\bin\pg_basebackup\streamutil.h" />
|
||||
<ClInclude Include="@PGSRC@\bin\pg_rewind\datapagemap.h" />
|
||||
<ClInclude Include="@PGSRC@\bin\pg_rewind\logging.h" />
|
||||
<ClInclude Include="..\src\pg_probackup.h" />
|
||||
<ClInclude Include="..\src\utils\configuration.h" />
|
||||
<ClInclude Include="..\src\utils\logger.h" />
|
||||
<ClInclude Include="..\src\utils\parray.h" />
|
||||
<ClInclude Include="..\src\utils\pgut.h" />
|
||||
<ClInclude Include="..\src\utils\json.h" />
|
||||
<ClInclude Include="..\src\utils\thread.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@ -1,206 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{4886B21A-D8CA-4A03-BADF-743B24C88327}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>pg_probackup</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v120</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>../;@PGSRC@\include;@PGSRC@\bin\pg_basebackup;@PGSRC@\bin\pg_rewind;@PGSRC@\include\port\win32_msvc;@PGSRC@\interfaces\libpq;@PGSRC@\include\port\win32;@PGSRC@\port;@ADDINCLUDE@;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>@PGROOT@\lib;@$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>../;@PGSRC@\include;@PGSRC@\bin\pg_basebackup;@PGSRC@\bin\pg_rewind;@PGSRC@\include\port\win32_msvc;@PGSRC@\interfaces\libpq;@PGSRC@\include\port\win32;@PGSRC@\port;@ADDINCLUDE@;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>@PGROOT@\lib;@$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>../;@PGSRC@\include;@PGSRC@\bin\pg_basebackup;@PGSRC@\bin\pg_rewind;@PGSRC@\include\port\win32_msvc;@PGSRC@\interfaces\libpq;@PGSRC@\include\port\win32;@PGSRC@\port;@ADDINCLUDE@;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>@PGROOT@\lib;@$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>../;@PGSRC@\include;@PGSRC@\bin\pg_basebackup;@PGSRC@\bin\pg_rewind;@PGSRC@\include\port\win32_msvc;@PGSRC@\interfaces\libpq;@PGSRC@\include\port\win32;@PGSRC@\port;@ADDINCLUDE@;$(IncludePath)</IncludePath>
|
||||
<LibraryPath>@PGROOT@\lib;@$(LibraryPath)</LibraryPath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>@ADDLIBS@;libpgfeutils.lib;libpgcommon.lib;libpgport.lib;libpq.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<AdditionalDependencies>@ADDLIBS@;libpgfeutils.lib;libpgcommon.lib;libpgport.lib;libpq.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>@ADDLIBS@;libpgfeutils.lib;libpgcommon.lib;libpgport.lib;libpq.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<SDLCheck>true</SDLCheck>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<AdditionalDependencies>@ADDLIBS@;libpgfeutils.lib;libpgcommon.lib;libpgport.lib;libpq.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<IgnoreSpecificDefaultLibraries>libc;%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<!-- @PGROOT@\lib;@ADDLIBS@ @PGSRC@ @ADDINCLUDE@ -->
|
||||
<ItemGroup>
|
||||
<ClCompile Include="@PGSRC@\backend\access\transam\xlogreader.c" />
|
||||
<ClCompile Include="@PGSRC@\backend\utils\hash\pg_crc.c" />
|
||||
<ClCompile Include="@PGSRC@\bin\pg_basebackup\receivelog.c" />
|
||||
<ClCompile Include="@PGSRC@\bin\pg_basebackup\streamutil.c" />
|
||||
<ClCompile Include="@PGSRC@\bin\pg_basebackup\walmethods.c" />
|
||||
<ClCompile Include="@PGSRC@\bin\pg_rewind\datapagemap.c" />
|
||||
<ClCompile Include="@PGSRC@\interfaces\libpq\pthread-win32.c" />
|
||||
<ClCompile Include="..\src\archive.c" />
|
||||
<ClCompile Include="..\src\backup.c" />
|
||||
<ClCompile Include="..\src\catalog.c" />
|
||||
<ClCompile Include="..\src\configure.c" />
|
||||
<ClCompile Include="..\src\data.c" />
|
||||
<ClCompile Include="..\src\delete.c" />
|
||||
<ClCompile Include="..\src\dir.c" />
|
||||
<ClCompile Include="..\src\fetch.c" />
|
||||
<ClCompile Include="..\src\help.c" />
|
||||
<ClCompile Include="..\src\init.c" />
|
||||
<ClCompile Include="..\src\parsexlog.c" />
|
||||
<ClCompile Include="..\src\pg_probackup.c" />
|
||||
<ClCompile Include="..\src\restore.c" />
|
||||
<ClCompile Include="..\src\show.c" />
|
||||
<ClCompile Include="..\src\status.c" />
|
||||
<ClCompile Include="..\src\util.c" />
|
||||
<ClCompile Include="..\src\utils\configuration.c" />
|
||||
<ClCompile Include="..\src\utils\logger.c" />
|
||||
<ClCompile Include="..\src\utils\parray.c" />
|
||||
<ClCompile Include="..\src\utils\pgut.c" />
|
||||
<ClCompile Include="..\src\validate.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="@PGSRC@\bin\pg_basebackup\receivelog.h" />
|
||||
<ClInclude Include="@PGSRC@\bin\pg_basebackup\streamutil.h" />
|
||||
<ClInclude Include="@PGSRC@\bin\pg_basebackup\walmethods.h" />
|
||||
<ClInclude Include="@PGSRC@\bin\pg_rewind\datapagemap.h" />
|
||||
<ClInclude Include="@PGSRC@\bin\pg_rewind\logging.h" />
|
||||
<ClInclude Include="..\src\pg_probackup.h" />
|
||||
<ClInclude Include="..\src\utils\configuration.h" />
|
||||
<ClInclude Include="..\src\utils\logger.h" />
|
||||
<ClInclude Include="..\src\utils\parray.h" />
|
||||
<ClInclude Include="..\src\utils\pgut.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
138
src/backup.c
138
src/backup.c
@ -22,6 +22,7 @@
|
||||
#include <unistd.h>
|
||||
|
||||
#include "utils/thread.h"
|
||||
#include <time.h>
|
||||
|
||||
#define PG_STOP_BACKUP_TIMEOUT 300
|
||||
|
||||
@ -480,6 +481,9 @@ do_backup_instance(void)
|
||||
|
||||
pgBackup *prev_backup = NULL;
|
||||
parray *prev_backup_filelist = NULL;
|
||||
parray *backup_list = NULL;
|
||||
|
||||
pgFile *pg_control = NULL;
|
||||
|
||||
elog(LOG, "Database backup start");
|
||||
|
||||
@ -522,7 +526,6 @@ do_backup_instance(void)
|
||||
current.backup_mode == BACKUP_MODE_DIFF_PTRACK ||
|
||||
current.backup_mode == BACKUP_MODE_DIFF_DELTA)
|
||||
{
|
||||
parray *backup_list;
|
||||
char prev_backup_filelist_path[MAXPGPATH];
|
||||
|
||||
/* get list of backups already taken */
|
||||
@ -532,7 +535,6 @@ do_backup_instance(void)
|
||||
if (prev_backup == NULL)
|
||||
elog(ERROR, "Valid backup on current timeline is not found. "
|
||||
"Create new FULL backup before an incremental one.");
|
||||
parray_free(backup_list);
|
||||
|
||||
pgBackupGetPath(prev_backup, prev_backup_filelist_path,
|
||||
lengthof(prev_backup_filelist_path), DATABASE_FILE_LIST);
|
||||
@ -767,9 +769,35 @@ do_backup_instance(void)
|
||||
parray_free(prev_backup_filelist);
|
||||
}
|
||||
|
||||
/* In case of backup from replica >= 9.6 we must fix minRecPoint,
|
||||
* First we must find pg_control in backup_files_list.
|
||||
*/
|
||||
if (current.from_replica && !exclusive_backup)
|
||||
{
|
||||
char pg_control_path[MAXPGPATH];
|
||||
|
||||
snprintf(pg_control_path, sizeof(pg_control_path), "%s/%s",
|
||||
instance_config.pgdata, "global/pg_control");
|
||||
|
||||
for (i = 0; i < parray_num(backup_files_list); i++)
|
||||
{
|
||||
pgFile *tmp_file = (pgFile *) parray_get(backup_files_list, i);
|
||||
|
||||
if (strcmp(tmp_file->path, pg_control_path) == 0)
|
||||
{
|
||||
pg_control = tmp_file;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Notify end of backup */
|
||||
pg_stop_backup(¤t);
|
||||
|
||||
if (current.from_replica && !exclusive_backup)
|
||||
set_min_recovery_point(pg_control, database_path, current.stop_lsn);
|
||||
|
||||
/* Add archived xlog files into the list of files of this backup */
|
||||
if (stream_wal)
|
||||
{
|
||||
@ -803,7 +831,7 @@ do_backup_instance(void)
|
||||
}
|
||||
|
||||
/* Print the list of files to backup catalog */
|
||||
pgBackupWriteFileList(¤t, backup_files_list, instance_config.pgdata);
|
||||
write_backup_filelist(¤t, backup_files_list, instance_config.pgdata);
|
||||
|
||||
/* Compute summary of size of regular files in the backup */
|
||||
for (i = 0; i < parray_num(backup_files_list); i++)
|
||||
@ -818,6 +846,13 @@ do_backup_instance(void)
|
||||
current.data_bytes += file->write_size;
|
||||
}
|
||||
|
||||
/* Cleanup */
|
||||
if (backup_list)
|
||||
{
|
||||
parray_walk(backup_list, pgBackupFree);
|
||||
parray_free(backup_list);
|
||||
}
|
||||
|
||||
parray_walk(backup_files_list, pgFileFree);
|
||||
parray_free(backup_files_list);
|
||||
backup_files_list = NULL;
|
||||
@ -897,7 +932,7 @@ do_backup(time_t start_time)
|
||||
}
|
||||
}
|
||||
|
||||
if (current.from_replica)
|
||||
if (current.from_replica && exclusive_backup)
|
||||
{
|
||||
/* Check master connection options */
|
||||
if (instance_config.master_host == NULL)
|
||||
@ -1106,8 +1141,11 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
|
||||
|
||||
params[0] = label;
|
||||
|
||||
/* For replica we call pg_start_backup() on master */
|
||||
conn = (backup->from_replica) ? master_conn : backup_conn;
|
||||
/* For 9.5 replica we call pg_start_backup() on master */
|
||||
if (backup->from_replica && exclusive_backup)
|
||||
conn = master_conn;
|
||||
else
|
||||
conn = backup_conn;
|
||||
|
||||
/* 2nd argument is 'fast'*/
|
||||
params[1] = smooth ? "false" : "true";
|
||||
@ -1135,16 +1173,18 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
|
||||
|
||||
PQclear(res);
|
||||
|
||||
if (current.backup_mode == BACKUP_MODE_DIFF_PAGE)
|
||||
if (current.backup_mode == BACKUP_MODE_DIFF_PAGE &&
|
||||
(!(backup->from_replica && !exclusive_backup)))
|
||||
/*
|
||||
* Switch to a new WAL segment. It is necessary to get archived WAL
|
||||
* segment, which includes start LSN of current backup.
|
||||
* Don`t do this for replica backups unless it`s PG 9.5
|
||||
*/
|
||||
pg_switch_wal(conn);
|
||||
|
||||
if (current.backup_mode == BACKUP_MODE_DIFF_PAGE)
|
||||
/* In PAGE mode wait for current segment... */
|
||||
wait_wal_lsn(backup->start_lsn, true, false);
|
||||
wait_wal_lsn(backup->start_lsn, true, false);
|
||||
/*
|
||||
* Do not wait start_lsn for stream backup.
|
||||
* Because WAL streaming will start after pg_start_backup() in stream
|
||||
@ -1154,8 +1194,10 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
|
||||
/* ...for others wait for previous segment */
|
||||
wait_wal_lsn(backup->start_lsn, true, true);
|
||||
|
||||
/* Wait for start_lsn to be replayed by replica */
|
||||
if (backup->from_replica)
|
||||
/* In case of backup from replica for PostgreSQL 9.5
|
||||
* wait for start_lsn to be replayed by replica
|
||||
*/
|
||||
if (backup->from_replica && exclusive_backup)
|
||||
wait_replica_wal_lsn(backup->start_lsn, true);
|
||||
}
|
||||
|
||||
@ -1510,7 +1552,7 @@ wait_wal_lsn(XLogRecPtr lsn, bool is_start_lsn, bool wait_prev_segment)
|
||||
instance_config.xlog_seg_size);
|
||||
|
||||
/*
|
||||
* In pg_start_backup we wait for 'lsn' in 'pg_wal' directory iff it is
|
||||
* In pg_start_backup we wait for 'lsn' in 'pg_wal' directory if it is
|
||||
* stream and non-page backup. Page backup needs archived WAL files, so we
|
||||
* wait for 'lsn' in archive 'wal' directory for page backups.
|
||||
*
|
||||
@ -1531,7 +1573,11 @@ wait_wal_lsn(XLogRecPtr lsn, bool is_start_lsn, bool wait_prev_segment)
|
||||
{
|
||||
join_path_components(wal_segment_path, arclog_path, wal_segment);
|
||||
wal_segment_dir = arclog_path;
|
||||
timeout = instance_config.archive_timeout;
|
||||
|
||||
if (instance_config.archive_timeout > 0)
|
||||
timeout = instance_config.archive_timeout;
|
||||
else
|
||||
timeout = ARCHIVE_TIMEOUT_DEFAULT;
|
||||
}
|
||||
|
||||
if (wait_prev_segment)
|
||||
@ -1693,7 +1739,7 @@ pg_stop_backup(pgBackup *backup)
|
||||
PGresult *tablespace_map_content = NULL;
|
||||
uint32 lsn_hi;
|
||||
uint32 lsn_lo;
|
||||
XLogRecPtr restore_lsn = InvalidXLogRecPtr;
|
||||
//XLogRecPtr restore_lsn = InvalidXLogRecPtr;
|
||||
int pg_stop_backup_timeout = 0;
|
||||
char path[MAXPGPATH];
|
||||
char backup_label[MAXPGPATH];
|
||||
@ -1713,16 +1759,21 @@ pg_stop_backup(pgBackup *backup)
|
||||
if (!backup_in_progress)
|
||||
elog(ERROR, "backup is not in progress");
|
||||
|
||||
/* For replica we call pg_stop_backup() on master */
|
||||
conn = (current.from_replica) ? master_conn : backup_conn;
|
||||
/* For 9.5 replica we call pg_stop_backup() on master */
|
||||
if (current.from_replica && exclusive_backup)
|
||||
conn = master_conn;
|
||||
else
|
||||
conn = backup_conn;
|
||||
|
||||
/* Remove annoying NOTICE messages generated by backend */
|
||||
res = pgut_execute(conn, "SET client_min_messages = warning;",
|
||||
0, NULL);
|
||||
PQclear(res);
|
||||
|
||||
/* Create restore point */
|
||||
if (backup != NULL)
|
||||
/* Create restore point
|
||||
* only if it`s backup from master, or exclusive replica(wich connects to master)
|
||||
*/
|
||||
if (backup != NULL && (!current.from_replica || (current.from_replica && exclusive_backup)))
|
||||
{
|
||||
const char *params[1];
|
||||
char name[1024];
|
||||
@ -1740,7 +1791,7 @@ pg_stop_backup(pgBackup *backup)
|
||||
/* Extract timeline and LSN from the result */
|
||||
XLogDataFromLSN(PQgetvalue(res, 0, 0), &lsn_hi, &lsn_lo);
|
||||
/* Calculate LSN */
|
||||
restore_lsn = ((uint64) lsn_hi) << 32 | lsn_lo;
|
||||
//restore_lsn = ((uint64) lsn_hi) << 32 | lsn_lo;
|
||||
PQclear(res);
|
||||
}
|
||||
|
||||
@ -1761,14 +1812,29 @@ pg_stop_backup(pgBackup *backup)
|
||||
* Stop the non-exclusive backup. Besides stop_lsn it returns from
|
||||
* pg_stop_backup(false) copy of the backup label and tablespace map
|
||||
* so they can be written to disk by the caller.
|
||||
* In case of backup from replica >= 9.6 we do not trust minRecPoint
|
||||
* and stop_backup LSN, so we use latest replayed LSN as STOP LSN.
|
||||
*/
|
||||
stop_backup_query = "SELECT"
|
||||
" pg_catalog.txid_snapshot_xmax(pg_catalog.txid_current_snapshot()),"
|
||||
" current_timestamp(0)::timestamptz,"
|
||||
" lsn,"
|
||||
" labelfile,"
|
||||
" spcmapfile"
|
||||
" FROM pg_catalog.pg_stop_backup(false)";
|
||||
if (current.from_replica)
|
||||
stop_backup_query = "SELECT"
|
||||
" pg_catalog.txid_snapshot_xmax(pg_catalog.txid_current_snapshot()),"
|
||||
" current_timestamp(0)::timestamptz,"
|
||||
#if PG_VERSION_NUM >= 100000
|
||||
" pg_catalog.pg_last_wal_replay_lsn(),"
|
||||
#else
|
||||
" pg_catalog.pg_last_xlog_replay_location(),"
|
||||
#endif
|
||||
" labelfile,"
|
||||
" spcmapfile"
|
||||
" FROM pg_catalog.pg_stop_backup(false)";
|
||||
else
|
||||
stop_backup_query = "SELECT"
|
||||
" pg_catalog.txid_snapshot_xmax(pg_catalog.txid_current_snapshot()),"
|
||||
" current_timestamp(0)::timestamptz,"
|
||||
" lsn,"
|
||||
" labelfile,"
|
||||
" spcmapfile"
|
||||
" FROM pg_catalog.pg_stop_backup(false)";
|
||||
|
||||
}
|
||||
else
|
||||
@ -1856,13 +1922,13 @@ pg_stop_backup(pgBackup *backup)
|
||||
|
||||
if (!XRecOffIsValid(stop_backup_lsn))
|
||||
{
|
||||
stop_backup_lsn = restore_lsn;
|
||||
if (XRecOffIsNull(stop_backup_lsn))
|
||||
stop_backup_lsn = stop_backup_lsn + SizeOfXLogLongPHD;
|
||||
else
|
||||
elog(ERROR, "Invalid stop_backup_lsn value %X/%X",
|
||||
(uint32) (stop_backup_lsn >> 32), (uint32) (stop_backup_lsn));
|
||||
}
|
||||
|
||||
if (!XRecOffIsValid(stop_backup_lsn))
|
||||
elog(ERROR, "Invalid stop_backup_lsn value %X/%X",
|
||||
(uint32) (stop_backup_lsn >> 32), (uint32) (stop_backup_lsn));
|
||||
|
||||
/* Write backup_label and tablespace_map */
|
||||
if (!exclusive_backup)
|
||||
{
|
||||
@ -1963,7 +2029,7 @@ pg_stop_backup(pgBackup *backup)
|
||||
stream_xlog_path[MAXPGPATH];
|
||||
|
||||
/* Wait for stop_lsn to be received by replica */
|
||||
if (backup->from_replica)
|
||||
if (current.from_replica)
|
||||
wait_replica_wal_lsn(stop_backup_lsn, false);
|
||||
/*
|
||||
* Wait for stop_lsn to be archived or streamed.
|
||||
@ -1986,11 +2052,13 @@ pg_stop_backup(pgBackup *backup)
|
||||
|
||||
elog(LOG, "Getting the Recovery Time from WAL");
|
||||
|
||||
/* iterate over WAL from stop_backup lsn to start_backup lsn */
|
||||
if (!read_recovery_info(xlog_path, backup->tli,
|
||||
instance_config.xlog_seg_size,
|
||||
backup->start_lsn, backup->stop_lsn,
|
||||
&backup->recovery_time, &backup->recovery_xid))
|
||||
{
|
||||
elog(LOG, "Failed to find Recovery Time in WAL. Forced to trust current_timestamp");
|
||||
backup->recovery_time = recovery_time;
|
||||
backup->recovery_xid = recovery_xid;
|
||||
}
|
||||
@ -2099,7 +2167,7 @@ backup_files(void *arg)
|
||||
elog(ERROR, "interrupted during backup");
|
||||
|
||||
if (progress)
|
||||
elog(LOG, "Progress: (%d/%d). Process file \"%s\"",
|
||||
elog(INFO, "Progress: (%d/%d). Process file \"%s\"",
|
||||
i + 1, n_backup_files_list, file->path);
|
||||
|
||||
/* stat file to check its current state */
|
||||
@ -2130,7 +2198,7 @@ backup_files(void *arg)
|
||||
|
||||
if (S_ISREG(buf.st_mode))
|
||||
{
|
||||
pgFile **prev_file;
|
||||
pgFile **prev_file = NULL;
|
||||
|
||||
/* Check that file exist in previous backup */
|
||||
if (current.backup_mode != BACKUP_MODE_FULL)
|
||||
@ -2172,7 +2240,7 @@ backup_files(void *arg)
|
||||
bool skip = false;
|
||||
|
||||
/* If non-data file has not changed since last backup... */
|
||||
if (file->exists_in_prev &&
|
||||
if (prev_file && file->exists_in_prev &&
|
||||
buf.st_mtime < current.parent_backup)
|
||||
{
|
||||
calc_file_checksum(file);
|
||||
@ -2194,7 +2262,7 @@ backup_files(void *arg)
|
||||
file->path, file->write_size);
|
||||
}
|
||||
else
|
||||
elog(LOG, "unexpected file type %d", buf.st_mode);
|
||||
elog(WARNING, "unexpected file type %d", buf.st_mode);
|
||||
}
|
||||
|
||||
/* Close connection */
|
||||
|
@ -511,18 +511,22 @@ write_backup(pgBackup *backup)
|
||||
fp = fopen(conf_path, "wt");
|
||||
if (fp == NULL)
|
||||
elog(ERROR, "Cannot open configuration file \"%s\": %s", conf_path,
|
||||
strerror(errno));
|
||||
strerror(errno));
|
||||
|
||||
pgBackupWriteControl(fp, backup);
|
||||
|
||||
fclose(fp);
|
||||
if (fflush(fp) != 0 ||
|
||||
fsync(fileno(fp)) != 0 ||
|
||||
fclose(fp))
|
||||
elog(ERROR, "Cannot write configuration file \"%s\": %s",
|
||||
conf_path, strerror(errno));
|
||||
}
|
||||
|
||||
/*
|
||||
* Output the list of files to backup catalog DATABASE_FILE_LIST
|
||||
*/
|
||||
void
|
||||
pgBackupWriteFileList(pgBackup *backup, parray *files, const char *root)
|
||||
write_backup_filelist(pgBackup *backup, parray *files, const char *root)
|
||||
{
|
||||
FILE *fp;
|
||||
char path[MAXPGPATH];
|
||||
@ -531,7 +535,7 @@ pgBackupWriteFileList(pgBackup *backup, parray *files, const char *root)
|
||||
|
||||
fp = fopen(path, "wt");
|
||||
if (fp == NULL)
|
||||
elog(ERROR, "cannot open file list \"%s\": %s", path,
|
||||
elog(ERROR, "Cannot open file list \"%s\": %s", path,
|
||||
strerror(errno));
|
||||
|
||||
print_file_list(fp, files, root);
|
||||
@ -539,7 +543,7 @@ pgBackupWriteFileList(pgBackup *backup, parray *files, const char *root)
|
||||
if (fflush(fp) != 0 ||
|
||||
fsync(fileno(fp)) != 0 ||
|
||||
fclose(fp))
|
||||
elog(ERROR, "cannot write file list \"%s\": %s", path, strerror(errno));
|
||||
elog(ERROR, "Cannot write file list \"%s\": %s", path, strerror(errno));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -27,9 +27,6 @@ static void show_configure_end(void);
|
||||
static void show_configure_plain(ConfigOption *opt);
|
||||
static void show_configure_json(ConfigOption *opt);
|
||||
|
||||
#define ARCHIVE_TIMEOUT_DEFAULT 300
|
||||
#define REPLICA_TIMEOUT_DEFAULT 300
|
||||
|
||||
#define RETENTION_REDUNDANCY_DEFAULT 0
|
||||
#define RETENTION_WINDOW_DEFAULT 0
|
||||
|
||||
|
35
src/data.c
35
src/data.c
@ -14,6 +14,8 @@
|
||||
#include "storage/checksum_impl.h"
|
||||
#include <common/pg_lzcompress.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
@ -722,6 +724,7 @@ restore_data_file(const char *to_path, pgFile *file, bool allow_truncate,
|
||||
size_t read_len;
|
||||
DataPage compressed_page; /* used as read buffer */
|
||||
DataPage page;
|
||||
int32 uncompressed_size = 0;
|
||||
|
||||
/* File didn`t changed. Nothig to copy */
|
||||
if (file->write_size == BYTES_INVALID)
|
||||
@ -777,17 +780,23 @@ restore_data_file(const char *to_path, pgFile *file, bool allow_truncate,
|
||||
|
||||
Assert(header.compressed_size <= BLCKSZ);
|
||||
|
||||
/* read a page from file */
|
||||
read_len = fread(compressed_page.data, 1,
|
||||
MAXALIGN(header.compressed_size), in);
|
||||
if (read_len != MAXALIGN(header.compressed_size))
|
||||
elog(ERROR, "cannot read block %u of \"%s\" read %lu of %d",
|
||||
blknum, file->path, read_len, header.compressed_size);
|
||||
|
||||
/*
|
||||
* if page size is smaller than BLCKSZ, decompress the page.
|
||||
* BUGFIX for versions < 2.0.23: if page size is equal to BLCKSZ.
|
||||
* we have to check, whether it is compressed or not using
|
||||
* page_may_be_compressed() function.
|
||||
*/
|
||||
if (header.compressed_size != BLCKSZ
|
||||
|| page_may_be_compressed(compressed_page.data, file->compress_alg,
|
||||
backup_version))
|
||||
{
|
||||
int32 uncompressed_size = 0;
|
||||
const char *errormsg = NULL;
|
||||
|
||||
uncompressed_size = do_decompress(page.data, BLCKSZ,
|
||||
@ -820,7 +829,11 @@ restore_data_file(const char *to_path, pgFile *file, bool allow_truncate,
|
||||
blknum, file->path, strerror(errno));
|
||||
}
|
||||
|
||||
if (header.compressed_size < BLCKSZ)
|
||||
/* if we uncompressed the page - write page.data,
|
||||
* if page wasn't compressed -
|
||||
* write what we've read - compressed_page.data
|
||||
*/
|
||||
if (uncompressed_size == BLCKSZ)
|
||||
{
|
||||
if (fwrite(page.data, 1, BLCKSZ, out) != BLCKSZ)
|
||||
elog(ERROR, "cannot write block %u of \"%s\": %s",
|
||||
@ -828,7 +841,7 @@ restore_data_file(const char *to_path, pgFile *file, bool allow_truncate,
|
||||
}
|
||||
else
|
||||
{
|
||||
/* if page wasn't compressed, we've read full block */
|
||||
/* */
|
||||
if (fwrite(compressed_page.data, 1, BLCKSZ, out) != BLCKSZ)
|
||||
elog(ERROR, "cannot write block %u of \"%s\": %s",
|
||||
blknum, file->path, strerror(errno));
|
||||
@ -1026,22 +1039,6 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
* Move file from one backup to another.
|
||||
* We do not apply compression to these files, because
|
||||
* it is either small control file or already compressed cfs file.
|
||||
*/
|
||||
void
|
||||
move_file(const char *from_root, const char *to_root, pgFile *file)
|
||||
{
|
||||
char to_path[MAXPGPATH];
|
||||
|
||||
join_path_components(to_path, to_root, file->path + strlen(from_root) + 1);
|
||||
if (rename(file->path, to_path) == -1)
|
||||
elog(ERROR, "Cannot move file \"%s\" to path \"%s\": %s",
|
||||
file->path, to_path, strerror(errno));
|
||||
}
|
||||
|
||||
#ifdef HAVE_LIBZ
|
||||
/*
|
||||
* Show error during work with compressed file
|
||||
|
27
src/delete.c
27
src/delete.c
@ -14,7 +14,6 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static int delete_backup_files(pgBackup *backup);
|
||||
static void delete_walfiles(XLogRecPtr oldest_lsn, TimeLineID oldest_tli,
|
||||
uint32 xlog_seg_size);
|
||||
|
||||
@ -250,7 +249,7 @@ do_retention_purge(void)
|
||||
* Delete backup files of the backup and update the status of the backup to
|
||||
* BACKUP_STATUS_DELETED.
|
||||
*/
|
||||
static int
|
||||
void
|
||||
delete_backup_files(pgBackup *backup)
|
||||
{
|
||||
size_t i;
|
||||
@ -262,11 +261,15 @@ delete_backup_files(pgBackup *backup)
|
||||
* If the backup was deleted already, there is nothing to do.
|
||||
*/
|
||||
if (backup->status == BACKUP_STATUS_DELETED)
|
||||
return 0;
|
||||
{
|
||||
elog(WARNING, "Backup %s already deleted",
|
||||
base36enc(backup->start_time));
|
||||
return;
|
||||
}
|
||||
|
||||
time2iso(timestamp, lengthof(timestamp), backup->recovery_time);
|
||||
|
||||
elog(INFO, "delete: %s %s",
|
||||
elog(INFO, "Delete: %s %s",
|
||||
base36enc(backup->start_time), timestamp);
|
||||
|
||||
/*
|
||||
@ -288,17 +291,17 @@ delete_backup_files(pgBackup *backup)
|
||||
pgFile *file = (pgFile *) parray_get(files, i);
|
||||
|
||||
/* print progress */
|
||||
elog(VERBOSE, "delete file(%zd/%lu) \"%s\"", i + 1,
|
||||
elog(VERBOSE, "Delete file(%zd/%lu) \"%s\"", i + 1,
|
||||
(unsigned long) parray_num(files), file->path);
|
||||
|
||||
if (remove(file->path))
|
||||
{
|
||||
elog(WARNING, "can't remove \"%s\": %s", file->path,
|
||||
strerror(errno));
|
||||
parray_walk(files, pgFileFree);
|
||||
parray_free(files);
|
||||
|
||||
return 1;
|
||||
if (errno == ENOENT)
|
||||
elog(VERBOSE, "File \"%s\" is absent", file->path);
|
||||
else
|
||||
elog(ERROR, "Cannot remove \"%s\": %s", file->path,
|
||||
strerror(errno));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -306,7 +309,7 @@ delete_backup_files(pgBackup *backup)
|
||||
parray_free(files);
|
||||
backup->status = BACKUP_STATUS_DELETED;
|
||||
|
||||
return 0;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
|
171
src/merge.c
171
src/merge.c
@ -59,7 +59,7 @@ do_merge(time_t backup_id)
|
||||
if (instance_name == NULL)
|
||||
elog(ERROR, "required parameter is not specified: --instance");
|
||||
|
||||
elog(LOG, "Merge started");
|
||||
elog(INFO, "Merge started");
|
||||
|
||||
catalog_lock();
|
||||
|
||||
@ -77,7 +77,8 @@ do_merge(time_t backup_id)
|
||||
{
|
||||
if (backup->status != BACKUP_STATUS_OK &&
|
||||
/* It is possible that previous merging was interrupted */
|
||||
backup->status != BACKUP_STATUS_MERGING)
|
||||
backup->status != BACKUP_STATUS_MERGING &&
|
||||
backup->status != BACKUP_STATUS_DELETING)
|
||||
elog(ERROR, "Backup %s has status: %s",
|
||||
base36enc(backup->start_time), status2str(backup->status));
|
||||
|
||||
@ -128,17 +129,21 @@ do_merge(time_t backup_id)
|
||||
*/
|
||||
for (i = full_backup_idx; i > dest_backup_idx; i--)
|
||||
{
|
||||
pgBackup *to_backup = (pgBackup *) parray_get(backups, i);
|
||||
pgBackup *from_backup = (pgBackup *) parray_get(backups, i - 1);
|
||||
|
||||
merge_backups(to_backup, from_backup);
|
||||
full_backup = (pgBackup *) parray_get(backups, i);
|
||||
merge_backups(full_backup, from_backup);
|
||||
}
|
||||
|
||||
pgBackupValidate(full_backup);
|
||||
if (full_backup->status == BACKUP_STATUS_CORRUPT)
|
||||
elog(ERROR, "Merging of backup %s failed", base36enc(backup_id));
|
||||
|
||||
/* cleanup */
|
||||
parray_walk(backups, pgBackupFree);
|
||||
parray_free(backups);
|
||||
|
||||
elog(LOG, "Merge completed");
|
||||
elog(INFO, "Merge of backup %s completed", base36enc(backup_id));
|
||||
}
|
||||
|
||||
/*
|
||||
@ -159,18 +164,34 @@ merge_backups(pgBackup *to_backup, pgBackup *from_backup)
|
||||
control_file[MAXPGPATH];
|
||||
parray *files,
|
||||
*to_files;
|
||||
pthread_t *threads;
|
||||
merge_files_arg *threads_args;
|
||||
pthread_t *threads = NULL;
|
||||
merge_files_arg *threads_args = NULL;
|
||||
int i;
|
||||
bool merge_isok = true;
|
||||
|
||||
elog(LOG, "Merging backup %s with backup %s", from_backup_id, to_backup_id);
|
||||
elog(INFO, "Merging backup %s with backup %s", from_backup_id, to_backup_id);
|
||||
|
||||
to_backup->status = BACKUP_STATUS_MERGING;
|
||||
write_backup_status(to_backup);
|
||||
/*
|
||||
* Validate to_backup only if it is BACKUP_STATUS_OK. If it has
|
||||
* BACKUP_STATUS_MERGING status then it isn't valid backup until merging
|
||||
* finished.
|
||||
*/
|
||||
if (to_backup->status == BACKUP_STATUS_OK)
|
||||
{
|
||||
pgBackupValidate(to_backup);
|
||||
if (to_backup->status == BACKUP_STATUS_CORRUPT)
|
||||
elog(ERROR, "Interrupt merging");
|
||||
}
|
||||
|
||||
from_backup->status = BACKUP_STATUS_MERGING;
|
||||
write_backup_status(from_backup);
|
||||
/*
|
||||
* It is OK to validate from_backup if it has BACKUP_STATUS_OK or
|
||||
* BACKUP_STATUS_MERGING status.
|
||||
*/
|
||||
Assert(from_backup->status == BACKUP_STATUS_OK ||
|
||||
from_backup->status == BACKUP_STATUS_MERGING);
|
||||
pgBackupValidate(from_backup);
|
||||
if (from_backup->status == BACKUP_STATUS_CORRUPT)
|
||||
elog(ERROR, "Interrupt merging");
|
||||
|
||||
/*
|
||||
* Make backup paths.
|
||||
@ -182,8 +203,6 @@ merge_backups(pgBackup *to_backup, pgBackup *from_backup)
|
||||
pgBackupGetPath(from_backup, from_database_path, lengthof(from_database_path),
|
||||
DATABASE_DIR);
|
||||
|
||||
create_data_directories(to_database_path, from_backup_path, false);
|
||||
|
||||
/*
|
||||
* Get list of files which will be modified or removed.
|
||||
*/
|
||||
@ -204,6 +223,21 @@ merge_backups(pgBackup *to_backup, pgBackup *from_backup)
|
||||
/* sort by size for load balancing */
|
||||
parray_qsort(files, pgFileCompareSize);
|
||||
|
||||
/*
|
||||
* Previous merging was interrupted during deleting source backup. It is
|
||||
* safe just to delete it again.
|
||||
*/
|
||||
if (from_backup->status == BACKUP_STATUS_DELETING)
|
||||
goto delete_source_backup;
|
||||
|
||||
to_backup->status = BACKUP_STATUS_MERGING;
|
||||
write_backup_status(to_backup);
|
||||
|
||||
from_backup->status = BACKUP_STATUS_MERGING;
|
||||
write_backup_status(from_backup);
|
||||
|
||||
create_data_directories(to_database_path, from_backup_path, false);
|
||||
|
||||
threads = (pthread_t *) palloc(sizeof(pthread_t) * num_threads);
|
||||
threads_args = (merge_files_arg *) palloc(sizeof(merge_files_arg) * num_threads);
|
||||
|
||||
@ -243,68 +277,10 @@ merge_backups(pgBackup *to_backup, pgBackup *from_backup)
|
||||
if (!merge_isok)
|
||||
elog(ERROR, "Data files merging failed");
|
||||
|
||||
/*
|
||||
* Files were copied into to_backup and deleted from from_backup. Remove
|
||||
* remaining directories from from_backup.
|
||||
*/
|
||||
parray_qsort(files, pgFileComparePathDesc);
|
||||
for (i = 0; i < parray_num(files); i++)
|
||||
{
|
||||
pgFile *file = (pgFile *) parray_get(files, i);
|
||||
|
||||
if (!S_ISDIR(file->mode))
|
||||
continue;
|
||||
|
||||
if (rmdir(file->path))
|
||||
elog(ERROR, "Could not remove directory \"%s\": %s",
|
||||
file->path, strerror(errno));
|
||||
}
|
||||
if (rmdir(from_database_path))
|
||||
elog(ERROR, "Could not remove directory \"%s\": %s",
|
||||
from_database_path, strerror(errno));
|
||||
if (unlink(control_file))
|
||||
elog(ERROR, "Could not remove file \"%s\": %s",
|
||||
control_file, strerror(errno));
|
||||
|
||||
pgBackupGetPath(from_backup, control_file, lengthof(control_file),
|
||||
BACKUP_CONTROL_FILE);
|
||||
if (unlink(control_file))
|
||||
elog(ERROR, "Could not remove file \"%s\": %s",
|
||||
control_file, strerror(errno));
|
||||
|
||||
if (rmdir(from_backup_path))
|
||||
elog(ERROR, "Could not remove directory \"%s\": %s",
|
||||
from_backup_path, strerror(errno));
|
||||
|
||||
/*
|
||||
* Delete files which are not in from_backup file list.
|
||||
*/
|
||||
for (i = 0; i < parray_num(to_files); i++)
|
||||
{
|
||||
pgFile *file = (pgFile *) parray_get(to_files, i);
|
||||
|
||||
if (parray_bsearch(files, file, pgFileComparePathDesc) == NULL)
|
||||
{
|
||||
pgFileDelete(file);
|
||||
elog(LOG, "Deleted \"%s\"", file->path);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Rename FULL backup directory.
|
||||
*/
|
||||
if (rename(to_backup_path, from_backup_path) == -1)
|
||||
elog(ERROR, "Could not rename directory \"%s\" to \"%s\": %s",
|
||||
to_backup_path, from_backup_path, strerror(errno));
|
||||
|
||||
/*
|
||||
* Update to_backup metadata.
|
||||
*/
|
||||
pgBackupCopy(to_backup, from_backup);
|
||||
/* Correct metadata */
|
||||
to_backup->backup_mode = BACKUP_MODE_FULL;
|
||||
to_backup->status = BACKUP_STATUS_OK;
|
||||
to_backup->parent_backup = INVALID_BACKUP_ID;
|
||||
/* Compute summary of size of regular files in the backup */
|
||||
to_backup->data_bytes = 0;
|
||||
for (i = 0; i < parray_num(files); i++)
|
||||
@ -325,12 +301,54 @@ merge_backups(pgBackup *to_backup, pgBackup *from_backup)
|
||||
else
|
||||
to_backup->wal_bytes = BYTES_INVALID;
|
||||
|
||||
pgBackupWriteFileList(to_backup, files, from_database_path);
|
||||
write_backup_filelist(to_backup, files, from_database_path);
|
||||
write_backup(to_backup);
|
||||
|
||||
delete_source_backup:
|
||||
/*
|
||||
* Files were copied into to_backup. It is time to remove source backup
|
||||
* entirely.
|
||||
*/
|
||||
delete_backup_files(from_backup);
|
||||
|
||||
/*
|
||||
* Delete files which are not in from_backup file list.
|
||||
*/
|
||||
for (i = 0; i < parray_num(to_files); i++)
|
||||
{
|
||||
pgFile *file = (pgFile *) parray_get(to_files, i);
|
||||
|
||||
if (parray_bsearch(files, file, pgFileComparePathDesc) == NULL)
|
||||
{
|
||||
pgFileDelete(file);
|
||||
elog(VERBOSE, "Deleted \"%s\"", file->path);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Rename FULL backup directory.
|
||||
*/
|
||||
elog(INFO, "Rename %s to %s", to_backup_id, from_backup_id);
|
||||
if (rename(to_backup_path, from_backup_path) == -1)
|
||||
elog(ERROR, "Could not rename directory \"%s\" to \"%s\": %s",
|
||||
to_backup_path, from_backup_path, strerror(errno));
|
||||
|
||||
/*
|
||||
* Merging finished, now we can safely update ID of the destination backup.
|
||||
*/
|
||||
pgBackupCopy(to_backup, from_backup);
|
||||
/* Correct metadata */
|
||||
to_backup->backup_mode = BACKUP_MODE_FULL;
|
||||
to_backup->status = BACKUP_STATUS_OK;
|
||||
to_backup->parent_backup = INVALID_BACKUP_ID;
|
||||
write_backup(to_backup);
|
||||
|
||||
/* Cleanup */
|
||||
pfree(threads_args);
|
||||
pfree(threads);
|
||||
if (threads)
|
||||
{
|
||||
pfree(threads_args);
|
||||
pfree(threads);
|
||||
}
|
||||
|
||||
parray_walk(to_files, pgFileFree);
|
||||
parray_free(to_files);
|
||||
@ -508,10 +526,9 @@ merge_files(void *arg)
|
||||
file->write_size = pgFileSize(to_path_tmp);
|
||||
file->crc = pgFileGetCRC(to_path_tmp, false);
|
||||
}
|
||||
pgFileDelete(file);
|
||||
}
|
||||
else
|
||||
move_file(argument->from_root, argument->to_root, file);
|
||||
copy_file(argument->from_root, argument->to_root, file);
|
||||
|
||||
if (file->write_size != BYTES_INVALID)
|
||||
elog(LOG, "Moved file \"%s\": " INT64_FORMAT " bytes",
|
||||
|
@ -22,6 +22,8 @@
|
||||
#endif
|
||||
|
||||
#include "utils/thread.h"
|
||||
#include <unistd.h>
|
||||
#include <time.h>
|
||||
|
||||
/*
|
||||
* RmgrNames is an array of resource manager names, to make error messages
|
||||
@ -237,10 +239,11 @@ doExtractPageMap(void *arg)
|
||||
*/
|
||||
if (XLogRecPtrIsInvalid(found))
|
||||
{
|
||||
elog(WARNING, "Thread [%d]: could not read WAL record at %X/%X",
|
||||
elog(WARNING, "Thread [%d]: could not read WAL record at %X/%X. %s",
|
||||
private_data->thread_num,
|
||||
(uint32) (extract_arg->startpoint >> 32),
|
||||
(uint32) (extract_arg->startpoint));
|
||||
(uint32) (extract_arg->startpoint),
|
||||
(xlogreader->errormsg_buf[0] != '\0')?xlogreader->errormsg_buf:"");
|
||||
PrintXLogCorruptionMsg(private_data, ERROR);
|
||||
}
|
||||
extract_arg->startpoint = found;
|
||||
@ -533,8 +536,8 @@ validate_wal(pgBackup *backup, const char *archivedir,
|
||||
*/
|
||||
if (backup->stream)
|
||||
{
|
||||
snprintf(backup_xlog_path, sizeof(backup_xlog_path), "/%s/%s/%s/%s",
|
||||
backup_instance_path, backup_id, DATABASE_DIR, PG_XLOG_DIR);
|
||||
pgBackupGetPath2(backup, backup_xlog_path, lengthof(backup_xlog_path),
|
||||
DATABASE_DIR, PG_XLOG_DIR);
|
||||
|
||||
validate_backup_wal_from_start_to_stop(backup, backup_xlog_path, tli,
|
||||
seg_size);
|
||||
|
@ -17,8 +17,9 @@
|
||||
|
||||
#include "utils/configuration.h"
|
||||
#include "utils/thread.h"
|
||||
#include <time.h>
|
||||
|
||||
const char *PROGRAM_VERSION = "2.0.23";
|
||||
const char *PROGRAM_VERSION = "2.0.24";
|
||||
const char *PROGRAM_URL = "https://github.com/postgrespro/pg_probackup";
|
||||
const char *PROGRAM_EMAIL = "https://github.com/postgrespro/pg_probackup/issues";
|
||||
|
||||
|
@ -49,6 +49,10 @@
|
||||
#define PG_BLACK_LIST "black_list"
|
||||
#define PG_TABLESPACE_MAP_FILE "tablespace_map"
|
||||
|
||||
/* Timeout defaults */
|
||||
#define ARCHIVE_TIMEOUT_DEFAULT 300
|
||||
#define REPLICA_TIMEOUT_DEFAULT 300
|
||||
|
||||
/* Direcotry/File permission */
|
||||
#define DIR_PERMISSION (0700)
|
||||
#define FILE_PERMISSION (0600)
|
||||
@ -58,6 +62,10 @@
|
||||
#define XID_FMT "%u"
|
||||
#endif
|
||||
|
||||
/* Check if an XLogRecPtr value is pointed to 0 offset */
|
||||
#define XRecOffIsNull(xlrp) \
|
||||
((xlrp) % XLOG_BLCKSZ == 0)
|
||||
|
||||
typedef enum CompressAlg
|
||||
{
|
||||
NOT_DEFINED_COMPRESS = 0,
|
||||
@ -398,7 +406,6 @@ extern int do_restore_or_validate(time_t target_backup_id,
|
||||
extern bool satisfy_timeline(const parray *timelines, const pgBackup *backup);
|
||||
extern bool satisfy_recovery_target(const pgBackup *backup,
|
||||
const pgRecoveryTarget *rt);
|
||||
extern parray * readTimeLineHistory_probackup(TimeLineID targetTLI);
|
||||
extern pgRecoveryTarget *parseRecoveryTargetOptions(
|
||||
const char *target_time, const char *target_xid,
|
||||
const char *target_inclusive, TimeLineID target_tli, const char* target_lsn,
|
||||
@ -428,6 +435,7 @@ extern int do_show(time_t requested_backup_id);
|
||||
|
||||
/* in delete.c */
|
||||
extern void do_delete(time_t backup_id);
|
||||
extern void delete_backup_files(pgBackup *backup);
|
||||
extern int do_retention_purge(void);
|
||||
extern int do_delete_instance(void);
|
||||
|
||||
@ -458,10 +466,11 @@ extern pgBackup *catalog_get_last_data_backup(parray *backup_list,
|
||||
TimeLineID tli);
|
||||
extern void catalog_lock(void);
|
||||
extern void pgBackupWriteControl(FILE *out, pgBackup *backup);
|
||||
extern void pgBackupWriteFileList(pgBackup *backup, parray *files,
|
||||
extern void write_backup_filelist(pgBackup *backup, parray *files,
|
||||
const char *root);
|
||||
|
||||
extern void pgBackupGetPath(const pgBackup *backup, char *path, size_t len, const char *subdir);
|
||||
extern void pgBackupGetPath(const pgBackup *backup, char *path, size_t len,
|
||||
const char *subdir);
|
||||
extern void pgBackupGetPath2(const pgBackup *backup, char *path, size_t len,
|
||||
const char *subdir1, const char *subdir2);
|
||||
extern int pgBackupCreateDir(pgBackup *backup);
|
||||
@ -523,7 +532,6 @@ extern void restore_data_file(const char *to_path,
|
||||
bool write_header,
|
||||
uint32 backup_version);
|
||||
extern bool copy_file(const char *from_root, const char *to_root, pgFile *file);
|
||||
extern void move_file(const char *from_root, const char *to_root, pgFile *file);
|
||||
extern void push_wal_file(const char *from_path, const char *to_path,
|
||||
bool is_compress, bool overwrite);
|
||||
extern void get_wal_file(const char *from_path, const char *to_path);
|
||||
@ -559,6 +567,7 @@ extern uint64 get_system_identifier(char *pgdata);
|
||||
extern uint64 get_remote_system_identifier(PGconn *conn);
|
||||
extern uint32 get_data_checksum_version(bool safe);
|
||||
extern uint32 get_xlog_seg_size(char *pgdata_path);
|
||||
extern void set_min_recovery_point(pgFile *file, const char *backup_path, XLogRecPtr stop_backup_lsn);
|
||||
|
||||
extern void sanityChecks(void);
|
||||
extern void time2iso(char *buf, size_t len, time_t time);
|
||||
|
@ -33,6 +33,7 @@ static void restore_backup(pgBackup *backup);
|
||||
static void create_recovery_conf(time_t backup_id,
|
||||
pgRecoveryTarget *rt,
|
||||
pgBackup *backup);
|
||||
static parray *read_timeline_history(TimeLineID targetTLI);
|
||||
static void *restore_files(void *arg);
|
||||
static void remove_deleted_files(pgBackup *backup);
|
||||
|
||||
@ -139,7 +140,7 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
|
||||
|
||||
elog(LOG, "target timeline ID = %u", rt->recovery_target_tli);
|
||||
/* Read timeline history files from archives */
|
||||
timelines = readTimeLineHistory_probackup(rt->recovery_target_tli);
|
||||
timelines = read_timeline_history(rt->recovery_target_tli);
|
||||
|
||||
if (!satisfy_timeline(timelines, current_backup))
|
||||
{
|
||||
@ -150,6 +151,9 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
|
||||
/* Try to find another backup that satisfies target timeline */
|
||||
continue;
|
||||
}
|
||||
|
||||
parray_walk(timelines, pfree);
|
||||
parray_free(timelines);
|
||||
}
|
||||
|
||||
if (!satisfy_recovery_target(current_backup, rt))
|
||||
@ -735,7 +739,7 @@ create_recovery_conf(time_t backup_id,
|
||||
* based on readTimeLineHistory() in timeline.c
|
||||
*/
|
||||
parray *
|
||||
readTimeLineHistory_probackup(TimeLineID targetTLI)
|
||||
read_timeline_history(TimeLineID targetTLI)
|
||||
{
|
||||
parray *result;
|
||||
char path[MAXPGPATH];
|
||||
@ -824,8 +828,7 @@ readTimeLineHistory_probackup(TimeLineID targetTLI)
|
||||
entry = pgut_new(TimeLineHistoryEntry);
|
||||
entry->tli = targetTLI;
|
||||
/* LSN in target timeline is valid */
|
||||
/* TODO ensure that -1UL --> -1L fix is correct */
|
||||
entry->end = (uint32) (-1L << 32) | -1L;
|
||||
entry->end = InvalidXLogRecPtr;
|
||||
parray_insert(result, 0, entry);
|
||||
|
||||
return result;
|
||||
@ -857,7 +860,8 @@ satisfy_timeline(const parray *timelines, const pgBackup *backup)
|
||||
|
||||
timeline = (TimeLineHistoryEntry *) parray_get(timelines, i);
|
||||
if (backup->tli == timeline->tli &&
|
||||
backup->stop_lsn < timeline->end)
|
||||
(XLogRecPtrIsInvalid(timeline->end) ||
|
||||
backup->stop_lsn < timeline->end))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
92
src/util.c
92
src/util.c
@ -14,6 +14,10 @@
|
||||
|
||||
#include <time.h>
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
const char *
|
||||
base36enc(long unsigned int value)
|
||||
{
|
||||
@ -71,7 +75,8 @@ checkControlFile(ControlFileData *ControlFile)
|
||||
"Either the file is corrupt, or it has a different layout than this program\n"
|
||||
"is expecting. The results below are untrustworthy.");
|
||||
|
||||
if (ControlFile->pg_control_version % 65536 == 0 && ControlFile->pg_control_version / 65536 != 0)
|
||||
if ((ControlFile->pg_control_version % 65536 == 0 || ControlFile->pg_control_version % 65536 > 10000) &&
|
||||
ControlFile->pg_control_version / 65536 != 0)
|
||||
elog(ERROR, "possible byte ordering mismatch\n"
|
||||
"The byte ordering used to store the pg_control file might not match the one\n"
|
||||
"used by this program. In that case the results below would be incorrect, and\n"
|
||||
@ -100,6 +105,44 @@ digestControlFile(ControlFileData *ControlFile, char *src, size_t size)
|
||||
checkControlFile(ControlFile);
|
||||
}
|
||||
|
||||
/*
|
||||
* Write ControlFile to pg_control
|
||||
*/
|
||||
static void
|
||||
writeControlFile(ControlFileData *ControlFile, char *path)
|
||||
{
|
||||
int fd;
|
||||
char *buffer = NULL;
|
||||
|
||||
#if PG_VERSION_NUM >= 100000
|
||||
int ControlFileSize = PG_CONTROL_FILE_SIZE;
|
||||
#else
|
||||
int ControlFileSize = PG_CONTROL_SIZE;
|
||||
#endif
|
||||
|
||||
/* copy controlFileSize */
|
||||
buffer = pg_malloc(ControlFileSize);
|
||||
memcpy(buffer, ControlFile, sizeof(ControlFileData));
|
||||
|
||||
/* Write pg_control */
|
||||
unlink(path);
|
||||
fd = open(path,
|
||||
O_RDWR | O_CREAT | O_EXCL | PG_BINARY,
|
||||
S_IRUSR | S_IWUSR);
|
||||
|
||||
if (fd < 0)
|
||||
elog(ERROR, "Failed to open file: %s", path);
|
||||
|
||||
if (write(fd, buffer, ControlFileSize) != ControlFileSize)
|
||||
elog(ERROR, "Failed to overwrite file: %s", path);
|
||||
|
||||
if (fsync(fd) != 0)
|
||||
elog(ERROR, "Failed to fsync file: %s", path);
|
||||
|
||||
close(fd);
|
||||
pg_free(buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Utility shared by backup and restore to fetch the current timeline
|
||||
* used by a node.
|
||||
@ -252,6 +295,53 @@ get_data_checksum_version(bool safe)
|
||||
return ControlFile.data_checksum_version;
|
||||
}
|
||||
|
||||
/* MinRecoveryPoint 'as-is' is not to be trusted */
|
||||
void
|
||||
set_min_recovery_point(pgFile *file, const char *backup_path,
|
||||
XLogRecPtr stop_backup_lsn)
|
||||
{
|
||||
ControlFileData ControlFile;
|
||||
char *buffer;
|
||||
size_t size;
|
||||
char fullpath[MAXPGPATH];
|
||||
|
||||
/* First fetch file content */
|
||||
buffer = slurpFile(instance_config.pgdata, XLOG_CONTROL_FILE, &size, false);
|
||||
if (buffer == NULL)
|
||||
elog(ERROR, "ERROR");
|
||||
|
||||
digestControlFile(&ControlFile, buffer, size);
|
||||
|
||||
elog(LOG, "Current minRecPoint %X/%X",
|
||||
(uint32) (ControlFile.minRecoveryPoint >> 32),
|
||||
(uint32) ControlFile.minRecoveryPoint);
|
||||
|
||||
elog(LOG, "Setting minRecPoint to %X/%X",
|
||||
(uint32) (stop_backup_lsn >> 32),
|
||||
(uint32) stop_backup_lsn);
|
||||
|
||||
ControlFile.minRecoveryPoint = stop_backup_lsn;
|
||||
|
||||
/* Update checksum in pg_control header */
|
||||
INIT_CRC32C(ControlFile.crc);
|
||||
COMP_CRC32C(ControlFile.crc,
|
||||
(char *) &ControlFile,
|
||||
offsetof(ControlFileData, crc));
|
||||
FIN_CRC32C(ControlFile.crc);
|
||||
|
||||
/* paranoia */
|
||||
checkControlFile(&ControlFile);
|
||||
|
||||
/* overwrite pg_control */
|
||||
snprintf(fullpath, sizeof(fullpath), "%s/%s", backup_path, XLOG_CONTROL_FILE);
|
||||
writeControlFile(&ControlFile, fullpath);
|
||||
|
||||
/* Update pg_control checksum in backup_list */
|
||||
file->crc = pgFileGetCRC(fullpath, false);
|
||||
|
||||
pg_free(buffer);
|
||||
}
|
||||
|
||||
/*
|
||||
* Parse string representation of the server version.
|
||||
*/
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "logger.h"
|
||||
#include "pgut.h"
|
||||
#include "thread.h"
|
||||
#include <time.h>
|
||||
|
||||
#include "utils/configuration.h"
|
||||
|
||||
|
@ -9,8 +9,11 @@
|
||||
|
||||
#include "thread.h"
|
||||
|
||||
#ifdef WIN32
|
||||
DWORD main_tid = 0;
|
||||
#else
|
||||
pthread_t main_tid = 0;
|
||||
|
||||
#endif
|
||||
#ifdef WIN32
|
||||
#include <errno.h>
|
||||
|
||||
|
@ -28,7 +28,13 @@ extern int pthread_join(pthread_t th, void **thread_return);
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
extern DWORD main_tid;
|
||||
#else
|
||||
extern pthread_t main_tid;
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
extern int pthread_lock(pthread_mutex_t *mp);
|
||||
|
||||
|
@ -5,6 +5,7 @@ from datetime import datetime, timedelta
|
||||
import subprocess
|
||||
from sys import exit
|
||||
from time import sleep
|
||||
from shutil import copyfile
|
||||
|
||||
|
||||
module_name = 'archive'
|
||||
@ -39,8 +40,7 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
result = node.safe_psql("postgres", "SELECT * FROM t_heap")
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
options=["--log-level-file=verbose"])
|
||||
backup_dir, 'node', node)
|
||||
node.cleanup()
|
||||
|
||||
self.restore_node(
|
||||
@ -53,8 +53,7 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
# Make backup
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
options=["--log-level-file=verbose"])
|
||||
backup_dir, 'node', node)
|
||||
node.cleanup()
|
||||
|
||||
# Restore Database
|
||||
@ -253,7 +252,6 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
backup_dir, 'node', node,
|
||||
options=[
|
||||
"--archive-timeout=60",
|
||||
"--log-level-file=verbose",
|
||||
"--stream"]
|
||||
)
|
||||
# we should die here because exception is what we expect to happen
|
||||
@ -402,7 +400,7 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
||||
# @unittest.expectedFailure
|
||||
# @unittest.skip("skip")
|
||||
@unittest.skip("skip")
|
||||
def test_replica_archive(self):
|
||||
"""
|
||||
make node without archiving, take stream backup and
|
||||
@ -417,7 +415,7 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
initdb_params=['--data-checksums'],
|
||||
pg_options={
|
||||
'max_wal_senders': '2',
|
||||
'checkpoint_timeout': '30s',
|
||||
'archive_timeout': '10s',
|
||||
'max_wal_size': '1GB'}
|
||||
)
|
||||
self.init_pb(backup_dir)
|
||||
@ -433,7 +431,7 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
"postgres",
|
||||
"create table t_heap as select i as id, md5(i::text) as text, "
|
||||
"md5(repeat(i::text,10))::tsvector as tsvector "
|
||||
"from generate_series(0,256) i")
|
||||
"from generate_series(0,2560) i")
|
||||
|
||||
self.backup_node(backup_dir, 'master', master, options=['--stream'])
|
||||
before = master.safe_psql("postgres", "SELECT * FROM t_heap")
|
||||
@ -459,9 +457,6 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
"md5(repeat(i::text,10))::tsvector as tsvector "
|
||||
"from generate_series(256,512) i")
|
||||
before = master.safe_psql("postgres", "SELECT * FROM t_heap")
|
||||
# ADD INSTANCE 'REPLICA'
|
||||
|
||||
sleep(1)
|
||||
|
||||
backup_id = self.backup_node(
|
||||
backup_dir, 'replica', replica,
|
||||
@ -469,7 +464,9 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
'--archive-timeout=30',
|
||||
'--master-host=localhost',
|
||||
'--master-db=postgres',
|
||||
'--master-port={0}'.format(master.port)])
|
||||
'--master-port={0}'.format(master.port),
|
||||
'--stream'])
|
||||
|
||||
self.validate_pb(backup_dir, 'replica')
|
||||
self.assertEqual(
|
||||
'OK', self.show_pb(backup_dir, 'replica', backup_id)['status'])
|
||||
@ -493,16 +490,28 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
"postgres",
|
||||
"insert into t_heap as select i as id, md5(i::text) as text, "
|
||||
"md5(repeat(i::text,10))::tsvector as tsvector "
|
||||
"from generate_series(512,768) i")
|
||||
"from generate_series(512,20680) i")
|
||||
|
||||
before = master.safe_psql("postgres", "SELECT * FROM t_heap")
|
||||
|
||||
master.safe_psql(
|
||||
"postgres",
|
||||
"CHECKPOINT")
|
||||
|
||||
# copyfile(
|
||||
# os.path.join(backup_dir, 'wal/master/000000010000000000000002'),
|
||||
# os.path.join(backup_dir, 'wal/replica/000000010000000000000002'))
|
||||
|
||||
backup_id = self.backup_node(
|
||||
backup_dir, 'replica',
|
||||
replica, backup_type='page',
|
||||
options=[
|
||||
'--archive-timeout=30', '--log-level-file=verbose',
|
||||
'--master-host=localhost', '--master-db=postgres',
|
||||
'--master-port={0}'.format(master.port)]
|
||||
)
|
||||
'--archive-timeout=30',
|
||||
'--master-db=postgres',
|
||||
'--master-host=localhost',
|
||||
'--master-port={0}'.format(master.port),
|
||||
'--stream'])
|
||||
|
||||
self.validate_pb(backup_dir, 'replica')
|
||||
self.assertEqual(
|
||||
'OK', self.show_pb(backup_dir, 'replica', backup_id)['status'])
|
||||
@ -511,8 +520,10 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
node.cleanup()
|
||||
self.restore_node(
|
||||
backup_dir, 'replica', data_dir=node.data_dir, backup_id=backup_id)
|
||||
|
||||
node.append_conf(
|
||||
'postgresql.auto.conf', 'port = {0}'.format(node.port))
|
||||
|
||||
node.slow_start()
|
||||
# CHECK DATA CORRECTNESS
|
||||
after = node.safe_psql("postgres", "SELECT * FROM t_heap")
|
||||
@ -537,7 +548,7 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
set_replication=True,
|
||||
initdb_params=['--data-checksums'],
|
||||
pg_options={
|
||||
'checkpoint_timeout': '30s'}
|
||||
'archive_timeout': '10s'}
|
||||
)
|
||||
replica = self.make_simple_node(
|
||||
base_dir="{0}/{1}/replica".format(module_name, fname))
|
||||
@ -568,7 +579,7 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
pgdata_replica = self.pgdata_content(replica.data_dir)
|
||||
self.compare_pgdata(pgdata_master, pgdata_replica)
|
||||
|
||||
self.set_replica(master, replica, synchronous=True)
|
||||
self.set_replica(master, replica)
|
||||
# ADD INSTANCE REPLICA
|
||||
self.add_instance(backup_dir, 'replica', replica)
|
||||
# SET ARCHIVING FOR REPLICA
|
||||
@ -579,16 +590,26 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
after = replica.safe_psql("postgres", "SELECT * FROM t_heap")
|
||||
self.assertEqual(before, after)
|
||||
|
||||
master.psql(
|
||||
"postgres",
|
||||
"insert into t_heap select i as id, md5(i::text) as text, "
|
||||
"md5(repeat(i::text,10))::tsvector as tsvector "
|
||||
"from generate_series(0, 60000) i")
|
||||
|
||||
# TAKE FULL ARCHIVE BACKUP FROM REPLICA
|
||||
copyfile(
|
||||
os.path.join(backup_dir, 'wal/master/000000010000000000000001'),
|
||||
os.path.join(backup_dir, 'wal/replica/000000010000000000000001'))
|
||||
|
||||
backup_id = self.backup_node(
|
||||
backup_dir, 'replica', replica,
|
||||
options=[
|
||||
'--archive-timeout=20',
|
||||
'--log-level-file=verbose',
|
||||
'--archive-timeout=30',
|
||||
'--master-host=localhost',
|
||||
'--master-db=postgres',
|
||||
'--master-port={0}'.format(master.port)]
|
||||
)
|
||||
'--master-port={0}'.format(master.port),
|
||||
'--stream'])
|
||||
|
||||
self.validate_pb(backup_dir, 'replica')
|
||||
self.assertEqual(
|
||||
'OK', self.show_pb(backup_dir, 'replica', backup_id)['status'])
|
||||
@ -618,7 +639,8 @@ class ArchiveTest(ProbackupTest, unittest.TestCase):
|
||||
set_replication=True,
|
||||
initdb_params=['--data-checksums'],
|
||||
pg_options={
|
||||
'checkpoint_timeout': '30s'}
|
||||
'checkpoint_timeout': '30s',
|
||||
'archive_timeout': '10s'}
|
||||
)
|
||||
replica = self.make_simple_node(
|
||||
base_dir="{0}/{1}/replica".format(module_name, fname))
|
||||
|
@ -328,7 +328,7 @@ class BackupTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type="full",
|
||||
options=["-j", "4", "--stream", '--log-level-file=verbose'])
|
||||
options=["-j", "4", "--stream", "--log-level-file=verbose"])
|
||||
|
||||
# open log file and check
|
||||
with open(os.path.join(backup_dir, 'log', 'pg_probackup.log')) as f:
|
||||
|
@ -94,8 +94,7 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
|
||||
pgbench.stdout.close()
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='page',
|
||||
options=['--log-level-file=verbose'])
|
||||
backup_dir, 'node', node, backup_type='page')
|
||||
|
||||
if self.paranoia:
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
@ -195,8 +194,7 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
|
||||
pgbench.stdout.close()
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='delta',
|
||||
options=['--log-level-file=verbose'])
|
||||
backup_dir, 'node', node, backup_type='delta')
|
||||
|
||||
if self.paranoia:
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
@ -296,8 +294,7 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
|
||||
pgbench.stdout.close()
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='delta',
|
||||
options=['--log-level-file=verbose'])
|
||||
backup_dir, 'node', node, backup_type='delta')
|
||||
|
||||
if self.paranoia:
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
@ -311,3 +308,162 @@ class CompatibilityTest(ProbackupTest, unittest.TestCase):
|
||||
if self.paranoia:
|
||||
pgdata_restored = self.pgdata_content(node_restored.data_dir)
|
||||
self.compare_pgdata(pgdata, pgdata_restored)
|
||||
|
||||
# @unittest.expectedFailure
|
||||
# @unittest.skip("skip")
|
||||
def test_backward_compatibility_compression(self):
|
||||
"""Description in jira issue PGPRO-434"""
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
node = self.make_simple_node(
|
||||
base_dir="{0}/{1}/node".format(module_name, fname),
|
||||
set_replication=True,
|
||||
initdb_params=['--data-checksums'],
|
||||
pg_options={
|
||||
'max_wal_senders': '2',
|
||||
'autovacuum': 'off'})
|
||||
|
||||
self.init_pb(backup_dir, old_binary=True)
|
||||
self.add_instance(backup_dir, 'node', node, old_binary=True)
|
||||
|
||||
self.set_archiving(backup_dir, 'node', node, old_binary=True)
|
||||
node.slow_start()
|
||||
|
||||
node.pgbench_init(scale=10)
|
||||
|
||||
# FULL backup with OLD binary
|
||||
backup_id = self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
old_binary=True,
|
||||
options=['--compress'])
|
||||
|
||||
if self.paranoia:
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
# restore OLD FULL with new binary
|
||||
node_restored = self.make_simple_node(
|
||||
base_dir="{0}/{1}/node_restored".format(module_name, fname))
|
||||
|
||||
node_restored.cleanup()
|
||||
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node_restored,
|
||||
options=["-j", "4"])
|
||||
|
||||
if self.paranoia:
|
||||
pgdata_restored = self.pgdata_content(node_restored.data_dir)
|
||||
self.compare_pgdata(pgdata, pgdata_restored)
|
||||
|
||||
# PAGE backup with OLD binary
|
||||
pgbench = node.pgbench(
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
options=["-c", "4", "-T", "10"])
|
||||
pgbench.wait()
|
||||
pgbench.stdout.close()
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
backup_type='page',
|
||||
old_binary=True,
|
||||
options=['--compress'])
|
||||
|
||||
if self.paranoia:
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
node_restored.cleanup()
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node_restored,
|
||||
options=["-j", "4"])
|
||||
|
||||
if self.paranoia:
|
||||
pgdata_restored = self.pgdata_content(node_restored.data_dir)
|
||||
self.compare_pgdata(pgdata, pgdata_restored)
|
||||
|
||||
# PAGE backup with new binary
|
||||
pgbench = node.pgbench(
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
options=["-c", "4", "-T", "10"])
|
||||
pgbench.wait()
|
||||
pgbench.stdout.close()
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
backup_type='page',
|
||||
options=['--compress'])
|
||||
|
||||
if self.paranoia:
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
node_restored.cleanup()
|
||||
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node_restored,
|
||||
options=["-j", "4"])
|
||||
|
||||
if self.paranoia:
|
||||
pgdata_restored = self.pgdata_content(node_restored.data_dir)
|
||||
self.compare_pgdata(pgdata, pgdata_restored)
|
||||
|
||||
# Delta backup with old binary
|
||||
self.delete_pb(backup_dir, 'node', backup_id)
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
old_binary=True,
|
||||
options=['--compress'])
|
||||
|
||||
pgbench = node.pgbench(
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
options=["-c", "4", "-T", "10"])
|
||||
|
||||
pgbench.wait()
|
||||
pgbench.stdout.close()
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
backup_type='delta',
|
||||
options=['--compress'],
|
||||
old_binary=True)
|
||||
|
||||
if self.paranoia:
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
node_restored.cleanup()
|
||||
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node_restored,
|
||||
options=["-j", "4"])
|
||||
|
||||
if self.paranoia:
|
||||
pgdata_restored = self.pgdata_content(node_restored.data_dir)
|
||||
self.compare_pgdata(pgdata, pgdata_restored)
|
||||
|
||||
# Delta backup with new binary
|
||||
pgbench = node.pgbench(
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.STDOUT,
|
||||
options=["-c", "4", "-T", "10"])
|
||||
|
||||
pgbench.wait()
|
||||
pgbench.stdout.close()
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
backup_type='delta',
|
||||
options=['--compress'])
|
||||
|
||||
if self.paranoia:
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
node_restored.cleanup()
|
||||
|
||||
self.restore_node(
|
||||
backup_dir, 'node', node_restored,
|
||||
options=["-j", "4"])
|
||||
|
||||
if self.paranoia:
|
||||
pgdata_restored = self.pgdata_content(node_restored.data_dir)
|
||||
self.compare_pgdata(pgdata, pgdata_restored)
|
||||
|
@ -55,9 +55,7 @@ class CompressionTest(ProbackupTest, unittest.TestCase):
|
||||
page_backup_id = self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='page',
|
||||
options=[
|
||||
'--stream', '--compress-algorithm=zlib',
|
||||
'--log-level-console=verbose',
|
||||
'--log-level-file=verbose'])
|
||||
'--stream', '--compress-algorithm=zlib'])
|
||||
|
||||
# PTRACK BACKUP
|
||||
node.safe_psql(
|
||||
@ -494,3 +492,68 @@ class CompressionTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
||||
@unittest.skip("skip")
|
||||
def test_uncompressable_pages(self):
|
||||
"""
|
||||
make archive node, create table with uncompressable toast pages,
|
||||
take backup with compression, make sure that page was not compressed,
|
||||
restore backup and check data correctness
|
||||
"""
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
node = self.make_simple_node(
|
||||
base_dir="{0}/{1}/node".format(module_name, fname),
|
||||
set_replication=True,
|
||||
initdb_params=['--data-checksums'],
|
||||
pg_options={
|
||||
'wal_level': 'replica',
|
||||
'max_wal_senders': '2',
|
||||
'checkpoint_timeout': '30s'}
|
||||
)
|
||||
|
||||
self.init_pb(backup_dir)
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
self.set_archiving(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
# node.safe_psql(
|
||||
# "postgres",
|
||||
# "create table t_heap as select i, "
|
||||
# "repeat('1234567890abcdefghiyklmn', 1)::bytea, "
|
||||
# "point(0,0) from generate_series(0,1) i")
|
||||
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"create table t as select i, "
|
||||
"repeat(md5(i::text),5006056) as fat_attr "
|
||||
"from generate_series(0,10) i;")
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
backup_type='full',
|
||||
options=[
|
||||
'--compress'])
|
||||
|
||||
node.cleanup()
|
||||
|
||||
self.restore_node(backup_dir, 'node', node)
|
||||
node.slow_start()
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
backup_type='full',
|
||||
options=[
|
||||
'--compress'])
|
||||
|
||||
# Clean after yourself
|
||||
# self.del_test_dir(module_name, fname)
|
||||
|
||||
# create table t as select i, repeat(md5('1234567890'), 1)::bytea, point(0,0) from generate_series(0,1) i;
|
||||
|
||||
|
||||
# create table t_bytea_1(file oid);
|
||||
# INSERT INTO t_bytea_1 (file)
|
||||
# VALUES (lo_import('/home/gsmol/git/postgres/contrib/pg_probackup/tests/expected/sample.random', 24593));
|
||||
# insert into t_bytea select string_agg(data,'') from pg_largeobject where pageno > 0;
|
||||
#
|
@ -80,13 +80,7 @@ class DeltaTest(ProbackupTest, unittest.TestCase):
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
self.restore_node(
|
||||
backup_dir,
|
||||
'node',
|
||||
node_restored,
|
||||
options=[
|
||||
"-j", "1",
|
||||
"--log-level-file=verbose"
|
||||
]
|
||||
backup_dir, 'node', node_restored
|
||||
)
|
||||
|
||||
# Physical comparison
|
||||
@ -176,8 +170,6 @@ class DeltaTest(ProbackupTest, unittest.TestCase):
|
||||
'node',
|
||||
node_restored,
|
||||
options=[
|
||||
"-j", "1",
|
||||
"--log-level-file=verbose",
|
||||
"-T", "{0}={1}".format(
|
||||
old_tablespace, new_tablespace)]
|
||||
)
|
||||
@ -251,13 +243,7 @@ class DeltaTest(ProbackupTest, unittest.TestCase):
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
self.restore_node(
|
||||
backup_dir,
|
||||
'node',
|
||||
node_restored,
|
||||
options=[
|
||||
"-j", "1",
|
||||
"--log-level-file=verbose"
|
||||
]
|
||||
backup_dir, 'node', node_restored
|
||||
)
|
||||
|
||||
# Physical comparison
|
||||
@ -683,7 +669,7 @@ class DeltaTest(ProbackupTest, unittest.TestCase):
|
||||
node_restored,
|
||||
backup_id=backup_id,
|
||||
options=[
|
||||
"-j", "4", "--log-level-file=verbose",
|
||||
"-j", "4",
|
||||
"--immediate",
|
||||
"--recovery-target-action=promote"])
|
||||
|
||||
@ -717,7 +703,7 @@ class DeltaTest(ProbackupTest, unittest.TestCase):
|
||||
node_restored,
|
||||
backup_id=backup_id,
|
||||
options=[
|
||||
"-j", "4", "--log-level-file=verbose",
|
||||
"-j", "4",
|
||||
"--immediate",
|
||||
"--recovery-target-action=promote"]
|
||||
)
|
||||
@ -815,7 +801,7 @@ class DeltaTest(ProbackupTest, unittest.TestCase):
|
||||
backup_id = self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
backup_type='delta',
|
||||
options=["--stream", "--log-level-file=verbose"]
|
||||
options=["--stream"]
|
||||
)
|
||||
# if self.paranoia:
|
||||
# pgdata_delta = self.pgdata_content(
|
||||
@ -844,7 +830,7 @@ class DeltaTest(ProbackupTest, unittest.TestCase):
|
||||
node_restored,
|
||||
backup_id=backup_id,
|
||||
options=[
|
||||
"-j", "4", "--log-level-file=verbose",
|
||||
"-j", "4",
|
||||
"--immediate",
|
||||
"--recovery-target-action=promote"])
|
||||
|
||||
@ -1135,7 +1121,7 @@ class DeltaTest(ProbackupTest, unittest.TestCase):
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
||||
# @unittest.skip("skip")
|
||||
def test_page_corruption_heal_via_ptrack_1(self):
|
||||
def test_delta_corruption_heal_via_ptrack_1(self):
|
||||
"""make node, corrupt some page, check that backup failed"""
|
||||
fname = self.id().split('.')[3]
|
||||
node = self.make_simple_node(
|
||||
@ -1174,8 +1160,10 @@ class DeltaTest(ProbackupTest, unittest.TestCase):
|
||||
f.close
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type="delta",
|
||||
options=["-j", "4", "--stream", "--log-level-file=verbose"])
|
||||
backup_dir, 'node', node,
|
||||
backup_type="delta",
|
||||
options=["-j", "4", "--stream", '--log-level-file=verbose'])
|
||||
|
||||
|
||||
# open log file and check
|
||||
with open(os.path.join(backup_dir, 'log', 'pg_probackup.log')) as f:
|
||||
|
@ -143,7 +143,7 @@ class ExcludeTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='ptrack',
|
||||
options=['--stream', '--log-level-file=verbose']
|
||||
options=['--stream']
|
||||
)
|
||||
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
@ -50,6 +50,7 @@ pg_probackup - utility to manage backup/recovery of PostgreSQL database.
|
||||
[--master-db=db_name] [--master-host=host_name]
|
||||
[--master-port=port] [--master-user=user_name]
|
||||
[--replica-timeout=timeout]
|
||||
[--skip-block-validation]
|
||||
|
||||
pg_probackup restore -B backup-path --instance=instance_name
|
||||
[-D pgdata-path] [-i backup-id] [--progress]
|
||||
@ -59,12 +60,14 @@ pg_probackup - utility to manage backup/recovery of PostgreSQL database.
|
||||
[--recovery-target-action=pause|promote|shutdown]
|
||||
[--restore-as-replica]
|
||||
[--no-validate]
|
||||
[--skip-block-validation]
|
||||
|
||||
pg_probackup validate -B backup-path [--instance=instance_name]
|
||||
[-i backup-id] [--progress]
|
||||
[--time=time|--xid=xid|--lsn=lsn [--inclusive=boolean]]
|
||||
[--recovery-target-name=target-name]
|
||||
[--timeline=timeline]
|
||||
[--skip-block-validation]
|
||||
|
||||
pg_probackup show -B backup-path
|
||||
[--instance=instance_name [-i backup-id]]
|
||||
|
@ -1 +1 @@
|
||||
pg_probackup 2.0.23
|
||||
pg_probackup 2.0.24
|
@ -143,7 +143,7 @@ class FalsePositive(ProbackupTest, unittest.TestCase):
|
||||
self.backup_node(backup_dir, 'node', node, options=['--stream'])
|
||||
gdb = self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='ptrack',
|
||||
options=['--stream', '--log-level-file=verbose'],
|
||||
options=['--stream'],
|
||||
gdb=True
|
||||
)
|
||||
|
||||
@ -227,7 +227,7 @@ class FalsePositive(ProbackupTest, unittest.TestCase):
|
||||
self.backup_node(backup_dir, 'node', node, options=['--stream'])
|
||||
gdb = self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='ptrack',
|
||||
options=['--stream', '--log-level-file=verbose'],
|
||||
options=['--stream'],
|
||||
gdb=True
|
||||
)
|
||||
|
||||
|
137
tests/merge.py
137
tests/merge.py
@ -2,7 +2,7 @@
|
||||
|
||||
import unittest
|
||||
import os
|
||||
from .helpers.ptrack_helpers import ProbackupTest
|
||||
from .helpers.ptrack_helpers import ProbackupTest, ProbackupException
|
||||
|
||||
module_name = "merge"
|
||||
|
||||
@ -407,17 +407,17 @@ class MergeTest(ProbackupTest, unittest.TestCase):
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"delete from t_heap where ctid >= '(11,0)'")
|
||||
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"vacuum t_heap")
|
||||
|
||||
self.backup_node(
|
||||
page_id = self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='ptrack')
|
||||
|
||||
if self.paranoia:
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
page_id = self.show_pb(backup_dir, "node")[1]["id"]
|
||||
self.merge_backup(backup_dir, "node", page_id)
|
||||
|
||||
self.validate_pb(backup_dir)
|
||||
@ -602,7 +602,7 @@ class MergeTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
gdb = self.merge_backup(backup_dir, "node", backup_id, gdb=True)
|
||||
|
||||
gdb.set_breakpoint('move_file')
|
||||
gdb.set_breakpoint('copy_file')
|
||||
gdb.run_until_break()
|
||||
|
||||
if gdb.continue_execution_until_break(20) != 'breakpoint-hit':
|
||||
@ -615,3 +615,132 @@ class MergeTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
# Try to continue failed MERGE
|
||||
self.merge_backup(backup_dir, "node", backup_id)
|
||||
|
||||
# Drop node and restore it
|
||||
node.cleanup()
|
||||
self.restore_node(backup_dir, 'node', node)
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
||||
# @unittest.skip("skip")
|
||||
def test_continue_failed_merge_with_corrupted_delta_backup(self):
|
||||
"""
|
||||
Fail merge via gdb, corrupt DELTA backup, try to continue merge
|
||||
"""
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
node = self.make_simple_node(
|
||||
base_dir="{0}/{1}/node".format(module_name, fname),
|
||||
set_replication=True, initdb_params=['--data-checksums'],
|
||||
pg_options={
|
||||
'wal_level': 'replica'
|
||||
}
|
||||
)
|
||||
|
||||
self.init_pb(backup_dir)
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
self.set_archiving(backup_dir, 'node', node)
|
||||
node.start()
|
||||
|
||||
# FULL backup
|
||||
self.backup_node(backup_dir, 'node', node)
|
||||
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"create table t_heap as select i as id,"
|
||||
" md5(i::text) as text, md5(i::text)::tsvector as tsvector"
|
||||
" from generate_series(0,1000) i"
|
||||
)
|
||||
|
||||
old_path = node.safe_psql(
|
||||
"postgres",
|
||||
"select pg_relation_filepath('t_heap')").rstrip()
|
||||
|
||||
# DELTA BACKUP
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='delta'
|
||||
)
|
||||
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"update t_heap set id = 100500"
|
||||
)
|
||||
|
||||
node.safe_psql(
|
||||
"postgres",
|
||||
"vacuum full t_heap"
|
||||
)
|
||||
|
||||
new_path = node.safe_psql(
|
||||
"postgres",
|
||||
"select pg_relation_filepath('t_heap')").rstrip()
|
||||
|
||||
# DELTA BACKUP
|
||||
backup_id_2 = self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='delta'
|
||||
)
|
||||
|
||||
backup_id = self.show_pb(backup_dir, "node")[1]["id"]
|
||||
|
||||
# Failed MERGE
|
||||
gdb = self.merge_backup(backup_dir, "node", backup_id, gdb=True)
|
||||
gdb.set_breakpoint('copy_file')
|
||||
gdb.run_until_break()
|
||||
|
||||
if gdb.continue_execution_until_break(2) != 'breakpoint-hit':
|
||||
print('Failed to hit breakpoint')
|
||||
exit(1)
|
||||
|
||||
gdb._execute('signal SIGKILL')
|
||||
|
||||
# CORRUPT incremental backup
|
||||
# read block from future
|
||||
# block_size + backup_header = 8200
|
||||
file = os.path.join(
|
||||
backup_dir, 'backups/node', backup_id_2, 'database', new_path)
|
||||
with open(file, 'rb') as f:
|
||||
f.seek(8200)
|
||||
block_1 = f.read(8200)
|
||||
f.close
|
||||
|
||||
# write block from future
|
||||
file = os.path.join(
|
||||
backup_dir, 'backups/node', backup_id, 'database', old_path)
|
||||
with open(file, 'r+b') as f:
|
||||
f.seek(8200)
|
||||
f.write(block_1)
|
||||
f.close
|
||||
|
||||
# Try to continue failed MERGE
|
||||
try:
|
||||
self.merge_backup(backup_dir, "node", backup_id)
|
||||
self.assertEqual(
|
||||
1, 0,
|
||||
"Expecting Error because of incremental backup corruption.\n "
|
||||
"Output: {0} \n CMD: {1}".format(
|
||||
repr(self.output), self.cmd))
|
||||
except ProbackupException as e:
|
||||
self.assertTrue(
|
||||
"WARNING: Backup {0} data files are corrupted".format(
|
||||
backup_id) in e.message and
|
||||
"ERROR: Merging of backup {0} failed".format(
|
||||
backup_id) in e.message,
|
||||
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
|
||||
repr(e.message), self.cmd))
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
||||
# 1. always use parent link when merging (intermediates may be from different chain)
|
||||
# 2. page backup we are merging with may disappear after failed merge,
|
||||
# it should not be possible to continue merge after that
|
||||
# PAGE_A MERGING (disappear)
|
||||
# FULL MERGING
|
||||
|
||||
# FULL MERGING
|
||||
|
||||
# PAGE_B OK (new backup)
|
||||
# FULL MERGING
|
||||
|
||||
# 3. Need new test with corrupted FULL backup
|
||||
|
@ -62,8 +62,7 @@ class PageBackupTest(ProbackupTest, unittest.TestCase):
|
||||
"vacuum t_heap")
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='page',
|
||||
options=['--log-level-file=verbose'])
|
||||
backup_dir, 'node', node, backup_type='page')
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='page')
|
||||
@ -333,8 +332,7 @@ class PageBackupTest(ProbackupTest, unittest.TestCase):
|
||||
result = node.safe_psql("postgres", "select * from pgbench_accounts")
|
||||
# PAGE BACKUP
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='page',
|
||||
options=["--log-level-file=verbose"])
|
||||
backup_dir, 'node', node, backup_type='page')
|
||||
# GET PHYSICAL CONTENT FROM NODE
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
@ -727,7 +725,7 @@ class PageBackupTest(ProbackupTest, unittest.TestCase):
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
backup_type='page',
|
||||
options=["-j", "4", '--log-level-file=verbose'])
|
||||
options=["-j", "4"])
|
||||
self.assertEqual(
|
||||
1, 0,
|
||||
"Expecting Error because of wal segment disappearance.\n "
|
||||
@ -797,8 +795,7 @@ class PageBackupTest(ProbackupTest, unittest.TestCase):
|
||||
# Single-thread PAGE backup
|
||||
try:
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
backup_type='page', options=['--log-level-file=verbose'])
|
||||
backup_dir, 'node', node, backup_type='page')
|
||||
self.assertEqual(
|
||||
1, 0,
|
||||
"Expecting Error because of wal segment disappearance.\n "
|
||||
@ -936,6 +933,8 @@ class PageBackupTest(ProbackupTest, unittest.TestCase):
|
||||
'INFO: Wait for LSN' in e.message and
|
||||
'in archived WAL segment' in e.message and
|
||||
'could not read WAL record at' in e.message and
|
||||
'WAL file is from different database system: WAL file database system identifier is' in e.message and
|
||||
'pg_control database system identifier is' in e.message and
|
||||
'Possible WAL corruption. Error has occured during reading WAL segment "{0}"'.format(
|
||||
file_destination) in e.message,
|
||||
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
|
||||
@ -961,6 +960,8 @@ class PageBackupTest(ProbackupTest, unittest.TestCase):
|
||||
'INFO: Wait for LSN' in e.message and
|
||||
'in archived WAL segment' in e.message and
|
||||
'could not read WAL record at' in e.message and
|
||||
'WAL file is from different database system: WAL file database system identifier is' in e.message and
|
||||
'pg_control database system identifier is' in e.message and
|
||||
'Possible WAL corruption. Error has occured during reading WAL segment "{0}"'.format(
|
||||
file_destination) in e.message,
|
||||
'\n Unexpected Error Message: {0}\n CMD: {1}'.format(
|
||||
|
@ -157,13 +157,13 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='ptrack',
|
||||
options=['--stream', '--log-level-file=verbose']
|
||||
options=['--stream']
|
||||
)
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='ptrack',
|
||||
options=['--stream', '--log-level-file=verbose']
|
||||
options=['--stream']
|
||||
)
|
||||
|
||||
self.restore_node(
|
||||
@ -246,14 +246,11 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
exit(1)
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='ptrack',
|
||||
options=['--log-level-file=verbose']
|
||||
)
|
||||
backup_dir, 'node', node, backup_type='ptrack')
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='ptrack',
|
||||
options=['--log-level-file=verbose']
|
||||
)
|
||||
backup_dir, 'node', node, backup_type='ptrack')
|
||||
|
||||
if self.paranoia:
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
@ -336,14 +333,10 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
)
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='ptrack',
|
||||
options=['--log-level-file=verbose']
|
||||
)
|
||||
backup_dir, 'node', node, backup_type='ptrack')
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='ptrack',
|
||||
options=['--log-level-file=verbose']
|
||||
)
|
||||
backup_dir, 'node', node, backup_type='ptrack')
|
||||
|
||||
if self.paranoia:
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
@ -409,7 +402,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='ptrack',
|
||||
options=['--stream', '--log-level-file=verbose']
|
||||
options=['--stream']
|
||||
)
|
||||
|
||||
node.safe_psql(
|
||||
@ -479,7 +472,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.backup_node(backup_dir, 'node', node, options=['--stream'])
|
||||
gdb = self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='ptrack',
|
||||
options=['--stream', '--log-level-file=verbose'],
|
||||
options=['--stream'],
|
||||
gdb=True
|
||||
)
|
||||
|
||||
@ -566,7 +559,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
ptrack_backup_id = self.backup_node(
|
||||
backup_dir, 'node',
|
||||
node, backup_type='ptrack',
|
||||
options=['--stream', '--log-level-file=verbose']
|
||||
options=['--stream']
|
||||
)
|
||||
|
||||
if self.paranoia:
|
||||
@ -989,7 +982,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
node.safe_psql("postgres", "SELECT * FROM t_heap")
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
options=["--stream", "--log-level-file=verbose"])
|
||||
options=["--stream"])
|
||||
|
||||
# CREATE DATABASE DB1
|
||||
node.safe_psql("postgres", "create database db1")
|
||||
@ -1002,7 +995,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
backup_id = self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
backup_type='ptrack',
|
||||
options=["--stream", "--log-level-file=verbose"]
|
||||
options=["--stream"]
|
||||
)
|
||||
|
||||
if self.paranoia:
|
||||
@ -1133,7 +1126,8 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
'-j10',
|
||||
'--master-host=localhost',
|
||||
'--master-db=postgres',
|
||||
'--master-port={0}'.format(node.port)
|
||||
'--master-port={0}'.format(node.port),
|
||||
'--stream'
|
||||
]
|
||||
)
|
||||
|
||||
@ -1229,7 +1223,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node,
|
||||
backup_type='ptrack',
|
||||
options=["--stream", "--log-level-file=verbose"]
|
||||
options=["--stream"]
|
||||
)
|
||||
if self.paranoia:
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
@ -1315,7 +1309,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
# PTRACK BACKUP
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='ptrack',
|
||||
options=["--stream", '--log-level-file=verbose'])
|
||||
options=["--stream"])
|
||||
|
||||
if self.paranoia:
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
@ -1476,7 +1470,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
# FIRTS PTRACK BACKUP
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='ptrack',
|
||||
options=["--stream", "--log-level-file=verbose"])
|
||||
options=["--stream"])
|
||||
|
||||
# GET PHYSICAL CONTENT FROM NODE
|
||||
if self.paranoia:
|
||||
@ -1517,7 +1511,7 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
# SECOND PTRACK BACKUP
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='ptrack',
|
||||
options=["--stream", "--log-level-file=verbose"])
|
||||
options=["--stream"])
|
||||
|
||||
if self.paranoia:
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
@ -1612,9 +1606,8 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
#result = node.safe_psql("postgres", "select * from pgbench_accounts")
|
||||
# FIRTS PTRACK BACKUP
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='ptrack',
|
||||
options=["--log-level-file=verbose"]
|
||||
)
|
||||
backup_dir, 'node', node, backup_type='ptrack')
|
||||
|
||||
# GET PHYSICAL CONTENT FROM NODE
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
||||
@ -1683,9 +1676,8 @@ class PtrackTest(ProbackupTest, unittest.TestCase):
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='ptrack',
|
||||
options=[
|
||||
"--stream", "-j 30",
|
||||
"--log-level-file=verbose"]
|
||||
)
|
||||
"--stream", "-j 30"])
|
||||
|
||||
# we should die here because exception is what we expect to happen
|
||||
self.assertEqual(
|
||||
1, 0,
|
||||
|
@ -76,7 +76,7 @@ class SimpleTest(ProbackupTest, unittest.TestCase):
|
||||
# Take PTRACK backup to clean every ptrack
|
||||
backup_id = self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='ptrack',
|
||||
options=['-j10', '--log-level-file=verbose'])
|
||||
options=['-j10'])
|
||||
node.safe_psql('postgres', 'checkpoint')
|
||||
|
||||
for i in idx_ptrack:
|
||||
|
@ -67,7 +67,7 @@ class SimpleTest(ProbackupTest, unittest.TestCase):
|
||||
# Take PTRACK backup
|
||||
backup_id = self.backup_node(
|
||||
backup_dir, 'node', node, backup_type='ptrack',
|
||||
options=['-j10', '--log-level-file=verbose'])
|
||||
options=['-j10'])
|
||||
|
||||
if self.paranoia:
|
||||
pgdata = self.pgdata_content(node.data_dir)
|
||||
|
272
tests/replica.py
272
tests/replica.py
@ -5,6 +5,7 @@ from datetime import datetime, timedelta
|
||||
import subprocess
|
||||
from sys import exit
|
||||
import time
|
||||
from shutil import copyfile
|
||||
|
||||
|
||||
module_name = 'replica'
|
||||
@ -64,6 +65,7 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
|
||||
"from generate_series(256,512) i")
|
||||
before = master.safe_psql("postgres", "SELECT * FROM t_heap")
|
||||
self.add_instance(backup_dir, 'replica', replica)
|
||||
|
||||
backup_id = self.backup_node(
|
||||
backup_dir, 'replica', replica,
|
||||
options=[
|
||||
@ -80,9 +82,11 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
|
||||
base_dir="{0}/{1}/node".format(module_name, fname))
|
||||
node.cleanup()
|
||||
self.restore_node(backup_dir, 'replica', data_dir=node.data_dir)
|
||||
|
||||
node.append_conf(
|
||||
'postgresql.auto.conf', 'port = {0}'.format(node.port))
|
||||
node.slow_start()
|
||||
|
||||
# CHECK DATA CORRECTNESS
|
||||
after = node.safe_psql("postgres", "SELECT * FROM t_heap")
|
||||
self.assertEqual(before, after)
|
||||
@ -95,7 +99,9 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
|
||||
"insert into t_heap as select i as id, md5(i::text) as text, "
|
||||
"md5(repeat(i::text,10))::tsvector as tsvector "
|
||||
"from generate_series(512,768) i")
|
||||
|
||||
before = master.safe_psql("postgres", "SELECT * FROM t_heap")
|
||||
|
||||
backup_id = self.backup_node(
|
||||
backup_dir, 'replica', replica, backup_type='ptrack',
|
||||
options=[
|
||||
@ -111,9 +117,11 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
|
||||
node.cleanup()
|
||||
self.restore_node(
|
||||
backup_dir, 'replica', data_dir=node.data_dir, backup_id=backup_id)
|
||||
|
||||
node.append_conf(
|
||||
'postgresql.auto.conf', 'port = {0}'.format(node.port))
|
||||
node.slow_start()
|
||||
|
||||
# CHECK DATA CORRECTNESS
|
||||
after = node.safe_psql("postgres", "SELECT * FROM t_heap")
|
||||
self.assertEqual(before, after)
|
||||
@ -136,13 +144,12 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
|
||||
pg_options={
|
||||
'wal_level': 'replica',
|
||||
'max_wal_senders': '2',
|
||||
'checkpoint_timeout': '30s'}
|
||||
'checkpoint_timeout': '30s',
|
||||
'archive_timeout': '10s'}
|
||||
)
|
||||
self.init_pb(backup_dir)
|
||||
self.add_instance(backup_dir, 'master', master)
|
||||
self.set_archiving(backup_dir, 'master', master)
|
||||
# force more frequent wal switch
|
||||
master.append_conf('postgresql.auto.conf', 'archive_timeout = 10')
|
||||
master.slow_start()
|
||||
|
||||
replica = self.make_simple_node(
|
||||
@ -155,7 +162,7 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
|
||||
"postgres",
|
||||
"create table t_heap as select i as id, md5(i::text) as text, "
|
||||
"md5(repeat(i::text,10))::tsvector as tsvector "
|
||||
"from generate_series(0,256) i")
|
||||
"from generate_series(0,2560) i")
|
||||
|
||||
before = master.safe_psql("postgres", "SELECT * FROM t_heap")
|
||||
|
||||
@ -166,6 +173,7 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
|
||||
# Settings for Replica
|
||||
self.set_replica(master, replica)
|
||||
self.set_archiving(backup_dir, 'replica', replica, replica=True)
|
||||
|
||||
replica.slow_start(replica=True)
|
||||
|
||||
# Check data correctness on replica
|
||||
@ -179,16 +187,32 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
|
||||
"postgres",
|
||||
"insert into t_heap as select i as id, md5(i::text) as text, "
|
||||
"md5(repeat(i::text,10))::tsvector as tsvector "
|
||||
"from generate_series(256,512) i")
|
||||
"from generate_series(256,5120) i")
|
||||
|
||||
before = master.safe_psql("postgres", "SELECT * FROM t_heap")
|
||||
self.add_instance(backup_dir, 'replica', replica)
|
||||
|
||||
copyfile(
|
||||
os.path.join(backup_dir, 'wal/master/000000010000000000000003'),
|
||||
os.path.join(backup_dir, 'wal/replica/000000010000000000000003'))
|
||||
|
||||
copyfile(
|
||||
os.path.join(backup_dir, 'wal/master/000000010000000000000004'),
|
||||
os.path.join(backup_dir, 'wal/replica/000000010000000000000004'))
|
||||
|
||||
copyfile(
|
||||
os.path.join(backup_dir, 'wal/master/000000010000000000000005'),
|
||||
os.path.join(backup_dir, 'wal/replica/000000010000000000000005'))
|
||||
|
||||
backup_id = self.backup_node(
|
||||
backup_dir, 'replica', replica,
|
||||
options=[
|
||||
'--archive-timeout=300',
|
||||
'--archive-timeout=30',
|
||||
'--master-host=localhost',
|
||||
'--master-db=postgres',
|
||||
'--master-port={0}'.format(master.port)])
|
||||
'--master-port={0}'.format(master.port),
|
||||
'--stream'])
|
||||
|
||||
self.validate_pb(backup_dir, 'replica')
|
||||
self.assertEqual(
|
||||
'OK', self.show_pb(backup_dir, 'replica', backup_id)['status'])
|
||||
@ -201,9 +225,11 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
|
||||
node.append_conf(
|
||||
'postgresql.auto.conf', 'port = {0}'.format(node.port))
|
||||
node.slow_start()
|
||||
|
||||
# CHECK DATA CORRECTNESS
|
||||
after = node.safe_psql("postgres", "SELECT * FROM t_heap")
|
||||
self.assertEqual(before, after)
|
||||
node.cleanup()
|
||||
|
||||
# Change data on master, make PAGE backup from replica,
|
||||
# restore taken backup and check that restored data equal
|
||||
@ -212,30 +238,42 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
|
||||
"postgres",
|
||||
"insert into t_heap as select i as id, md5(i::text) as text, "
|
||||
"md5(repeat(i::text,10))::tsvector as tsvector "
|
||||
"from generate_series(512,768) i")
|
||||
"from generate_series(512,22680) i")
|
||||
|
||||
before = master.safe_psql("postgres", "SELECT * FROM t_heap")
|
||||
|
||||
backup_id = self.backup_node(
|
||||
backup_dir, 'replica', replica, backup_type='page',
|
||||
backup_dir, 'replica',
|
||||
replica, backup_type='page',
|
||||
options=[
|
||||
'--archive-timeout=300',
|
||||
'--archive-timeout=30',
|
||||
'--master-host=localhost',
|
||||
'--master-db=postgres',
|
||||
'--master-port={0}'.format(master.port)])
|
||||
'--master-port={0}'.format(master.port),
|
||||
'--stream'])
|
||||
|
||||
self.validate_pb(backup_dir, 'replica')
|
||||
self.assertEqual(
|
||||
'OK', self.show_pb(backup_dir, 'replica', backup_id)['status'])
|
||||
|
||||
# RESTORE PAGE BACKUP TAKEN FROM replica
|
||||
node.cleanup()
|
||||
self.restore_node(
|
||||
backup_dir, 'replica', data_dir=node.data_dir, backup_id=backup_id)
|
||||
|
||||
node.append_conf(
|
||||
'postgresql.auto.conf', 'port = {0}'.format(node.port))
|
||||
node.append_conf(
|
||||
'postgresql.auto.conf', 'archive_mode = off')
|
||||
node.slow_start()
|
||||
|
||||
# CHECK DATA CORRECTNESS
|
||||
after = node.safe_psql("postgres", "SELECT * FROM t_heap")
|
||||
self.assertEqual(before, after)
|
||||
|
||||
self.add_instance(backup_dir, 'node', node)
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, options=['--stream'])
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
||||
@ -279,15 +317,217 @@ class ReplicaTest(ProbackupTest, unittest.TestCase):
|
||||
backup_id = self.backup_node(
|
||||
backup_dir, 'master', master, backup_type='page')
|
||||
self.restore_node(
|
||||
backup_dir, 'master', replica,
|
||||
options=['-R', '--recovery-target-action=promote'])
|
||||
backup_dir, 'master', replica, options=['-R'])
|
||||
|
||||
# Settings for Replica
|
||||
# self.set_replica(master, replica)
|
||||
self.set_archiving(backup_dir, 'replica', replica, replica=True)
|
||||
replica.append_conf(
|
||||
'postgresql.auto.conf', 'port = {0}'.format(replica.port))
|
||||
replica.start()
|
||||
replica.append_conf(
|
||||
'postgresql.auto.conf', 'hot_standby = on')
|
||||
|
||||
replica.slow_start(replica=True)
|
||||
|
||||
self.add_instance(backup_dir, 'replica', replica)
|
||||
|
||||
copyfile(
|
||||
os.path.join(backup_dir, 'wal/master/000000010000000000000003'),
|
||||
os.path.join(backup_dir, 'wal/replica/000000010000000000000003'))
|
||||
|
||||
self.backup_node(backup_dir, 'replica', replica)
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
||||
# @unittest.skip("skip")
|
||||
def test_take_backup_from_delayed_replica(self):
|
||||
"""
|
||||
make archive master, take full backups from master,
|
||||
restore full backup as delayed replica, launch pgbench,
|
||||
take FULL, PAGE and DELTA backups from replica
|
||||
"""
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
master = self.make_simple_node(
|
||||
base_dir="{0}/{1}/master".format(module_name, fname),
|
||||
set_replication=True,
|
||||
initdb_params=['--data-checksums'],
|
||||
pg_options={
|
||||
'wal_level': 'replica', 'max_wal_senders': '2',
|
||||
'checkpoint_timeout': '30s'}
|
||||
)
|
||||
self.init_pb(backup_dir)
|
||||
self.add_instance(backup_dir, 'master', master)
|
||||
self.set_archiving(backup_dir, 'master', master)
|
||||
# force more frequent wal switch
|
||||
#master.append_conf('postgresql.auto.conf', 'archive_timeout = 10')
|
||||
master.slow_start()
|
||||
|
||||
replica = self.make_simple_node(
|
||||
base_dir="{0}/{1}/replica".format(module_name, fname))
|
||||
replica.cleanup()
|
||||
|
||||
self.backup_node(backup_dir, 'master', master)
|
||||
|
||||
self.restore_node(
|
||||
backup_dir, 'master', replica, options=['-R'])
|
||||
|
||||
# Settings for Replica
|
||||
self.add_instance(backup_dir, 'replica', replica)
|
||||
self.set_archiving(backup_dir, 'replica', replica, replica=True)
|
||||
|
||||
# stupid hack
|
||||
copyfile(
|
||||
os.path.join(backup_dir, 'wal/master/000000010000000000000001'),
|
||||
os.path.join(backup_dir, 'wal/replica/000000010000000000000001'))
|
||||
|
||||
replica.append_conf(
|
||||
'postgresql.auto.conf', 'port = {0}'.format(replica.port))
|
||||
|
||||
replica.append_conf(
|
||||
'postgresql.auto.conf', 'hot_standby = on')
|
||||
|
||||
replica.append_conf(
|
||||
'recovery.conf', "recovery_min_apply_delay = '300s'")
|
||||
|
||||
replica.slow_start(replica=True)
|
||||
|
||||
master.pgbench_init(scale=10)
|
||||
|
||||
pgbench = master.pgbench(
|
||||
options=['-T', '30', '-c', '2', '--no-vacuum'])
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'replica', replica)
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'replica', replica,
|
||||
data_dir=replica.data_dir, backup_type='page')
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'replica', replica, backup_type='delta')
|
||||
|
||||
pgbench.wait()
|
||||
|
||||
pgbench = master.pgbench(
|
||||
options=['-T', '30', '-c', '2', '--no-vacuum'])
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'replica', replica,
|
||||
options=['--stream'])
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'replica', replica,
|
||||
backup_type='page', options=['--stream'])
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'replica', replica,
|
||||
backup_type='delta', options=['--stream'])
|
||||
|
||||
pgbench.wait()
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
||||
@unittest.skip("skip")
|
||||
def test_make_block_from_future(self):
|
||||
"""
|
||||
make archive master, take full backups from master,
|
||||
restore full backup as replica, launch pgbench,
|
||||
"""
|
||||
fname = self.id().split('.')[3]
|
||||
backup_dir = os.path.join(self.tmp_path, module_name, fname, 'backup')
|
||||
master = self.make_simple_node(
|
||||
base_dir="{0}/{1}/master".format(module_name, fname),
|
||||
set_replication=True,
|
||||
initdb_params=['--data-checksums'],
|
||||
pg_options={
|
||||
'wal_level': 'replica', 'max_wal_senders': '2',
|
||||
'checkpoint_timeout': '30s'}
|
||||
)
|
||||
self.init_pb(backup_dir)
|
||||
self.add_instance(backup_dir, 'master', master)
|
||||
self.set_archiving(backup_dir, 'master', master)
|
||||
# force more frequent wal switch
|
||||
#master.append_conf('postgresql.auto.conf', 'archive_timeout = 10')
|
||||
master.slow_start()
|
||||
|
||||
replica = self.make_simple_node(
|
||||
base_dir="{0}/{1}/replica".format(module_name, fname))
|
||||
replica.cleanup()
|
||||
|
||||
self.backup_node(backup_dir, 'master', master)
|
||||
|
||||
self.restore_node(
|
||||
backup_dir, 'master', replica, options=['-R'])
|
||||
|
||||
# Settings for Replica
|
||||
self.set_archiving(backup_dir, 'replica', replica, replica=True)
|
||||
replica.append_conf(
|
||||
'postgresql.auto.conf', 'port = {0}'.format(replica.port))
|
||||
replica.append_conf(
|
||||
'postgresql.auto.conf', 'hot_standby = on')
|
||||
|
||||
replica.slow_start(replica=True)
|
||||
|
||||
self.add_instance(backup_dir, 'replica', replica)
|
||||
|
||||
replica.safe_psql(
|
||||
'postgres',
|
||||
'checkpoint')
|
||||
|
||||
master.pgbench_init(scale=10)
|
||||
|
||||
self.wait_until_replica_catch_with_master(master, replica)
|
||||
|
||||
|
||||
# print(replica.safe_psql(
|
||||
# 'postgres',
|
||||
# 'select * from pg_catalog.pg_last_xlog_receive_location()'))
|
||||
#
|
||||
# print(replica.safe_psql(
|
||||
# 'postgres',
|
||||
# 'select * from pg_catalog.pg_last_xlog_replay_location()'))
|
||||
#
|
||||
# print(replica.safe_psql(
|
||||
# 'postgres',
|
||||
# 'select * from pg_catalog.pg_control_checkpoint()'))
|
||||
#
|
||||
# replica.safe_psql(
|
||||
# 'postgres',
|
||||
# 'checkpoint')
|
||||
|
||||
pgbench = master.pgbench(options=['-T', '30', '-c', '2', '--no-vacuum'])
|
||||
|
||||
time.sleep(5)
|
||||
|
||||
#self.backup_node(backup_dir, 'replica', replica, options=['--stream'])
|
||||
exit(1)
|
||||
self.backup_node(backup_dir, 'replica', replica)
|
||||
pgbench.wait()
|
||||
|
||||
# pgbench
|
||||
master.safe_psql(
|
||||
"postgres",
|
||||
"create table t_heap as select i as id, md5(i::text) as text, "
|
||||
"md5(repeat(i::text,10))::tsvector as tsvector "
|
||||
"from generate_series(0,256000) i")
|
||||
|
||||
|
||||
master.safe_psql(
|
||||
'postgres',
|
||||
'checkpoint')
|
||||
|
||||
replica.safe_psql(
|
||||
'postgres',
|
||||
'checkpoint')
|
||||
|
||||
replica.safe_psql(
|
||||
'postgres',
|
||||
'select * from pg_')
|
||||
|
||||
self.backup_node(backup_dir, 'replica', replica)
|
||||
exit(1)
|
||||
|
||||
# Clean after yourself
|
||||
self.del_test_dir(module_name, fname)
|
@ -50,7 +50,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
||||
f.close
|
||||
|
||||
self.backup_node(
|
||||
backup_dir, 'node', node, options=["--log-level-file=verbose"])
|
||||
backup_dir, 'node', node, options=['--log-level-file=verbose'])
|
||||
|
||||
log_file_path = os.path.join(backup_dir, "log", "pg_probackup.log")
|
||||
|
||||
@ -259,8 +259,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
||||
# Simple validate
|
||||
try:
|
||||
self.validate_pb(
|
||||
backup_dir, 'node', backup_id=backup_id_2,
|
||||
options=['--log-level-file=verbose'])
|
||||
backup_dir, 'node', backup_id=backup_id_2)
|
||||
self.assertEqual(
|
||||
1, 0,
|
||||
"Expecting Error because of data files corruption.\n "
|
||||
@ -364,8 +363,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
||||
# Validate PAGE1
|
||||
try:
|
||||
self.validate_pb(
|
||||
backup_dir, 'node', backup_id=backup_id_2,
|
||||
options=['--log-level-file=verbose'])
|
||||
backup_dir, 'node', backup_id=backup_id_2)
|
||||
self.assertEqual(
|
||||
1, 0,
|
||||
"Expecting Error because of data files corruption.\n "
|
||||
@ -520,8 +518,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
||||
try:
|
||||
self.validate_pb(
|
||||
backup_dir, 'node',
|
||||
backup_id=backup_id_4,
|
||||
options=['--log-level-file=verbose'])
|
||||
backup_id=backup_id_4)
|
||||
self.assertEqual(
|
||||
1, 0,
|
||||
"Expecting Error because of data files corruption.\n"
|
||||
@ -721,7 +718,6 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
||||
self.validate_pb(
|
||||
backup_dir, 'node',
|
||||
options=[
|
||||
'--log-level-file=verbose',
|
||||
'-i', backup_id_4, '--xid={0}'.format(target_xid)])
|
||||
self.assertEqual(
|
||||
1, 0,
|
||||
@ -866,7 +862,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
||||
# Validate Instance
|
||||
try:
|
||||
self.validate_pb(
|
||||
backup_dir, 'node', options=['--log-level-file=verbose'])
|
||||
backup_dir, 'node')
|
||||
self.assertEqual(
|
||||
1, 0,
|
||||
"Expecting Error because of data files corruption.\n "
|
||||
@ -1006,7 +1002,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
# Validate Instance
|
||||
try:
|
||||
self.validate_pb(backup_dir, 'node', options=['--log-level-file=verbose'])
|
||||
self.validate_pb(backup_dir, 'node')
|
||||
self.assertEqual(1, 0, "Expecting Error because of data files corruption.\n Output: {0} \n CMD: {1}".format(
|
||||
repr(self.output), self.cmd))
|
||||
except ProbackupException as e:
|
||||
@ -1092,7 +1088,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
# Validate Instance
|
||||
try:
|
||||
self.validate_pb(backup_dir, 'node', options=['--log-level-file=verbose'])
|
||||
self.validate_pb(backup_dir, 'node')
|
||||
self.assertEqual(1, 0, "Expecting Error because of data files corruption.\n Output: {0} \n CMD: {1}".format(
|
||||
repr(self.output), self.cmd))
|
||||
except ProbackupException as e:
|
||||
@ -1219,7 +1215,6 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
||||
'node',
|
||||
backup_id,
|
||||
options=[
|
||||
"--log-level-console=verbose",
|
||||
"--xid={0}".format(target_xid)])
|
||||
self.assertEqual(
|
||||
1, 0,
|
||||
@ -1388,7 +1383,6 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
||||
'node',
|
||||
backup_id,
|
||||
options=[
|
||||
"--log-level-console=verbose",
|
||||
"--xid={0}".format(target_xid)])
|
||||
self.assertEqual(
|
||||
1, 0,
|
||||
@ -1671,7 +1665,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
||||
|
||||
os.rename(file_new, file)
|
||||
try:
|
||||
self.validate_pb(backup_dir, options=['--log-level-file=verbose'])
|
||||
self.validate_pb(backup_dir)
|
||||
except ProbackupException as e:
|
||||
self.assertIn(
|
||||
'WARNING: Some backups are not valid'.format(
|
||||
@ -1776,7 +1770,7 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
||||
os.rename(file, file_new)
|
||||
|
||||
try:
|
||||
self.validate_pb(backup_dir, options=['--log-level-file=verbose'])
|
||||
self.validate_pb(backup_dir)
|
||||
except ProbackupException as e:
|
||||
self.assertIn(
|
||||
'WARNING: Some backups are not valid'.format(
|
||||
@ -3136,3 +3130,14 @@ class ValidateTest(ProbackupTest, unittest.TestCase):
|
||||
self.del_test_dir(module_name, fname)
|
||||
|
||||
# validate empty backup list
|
||||
# page from future during validate
|
||||
# page from future during backup
|
||||
|
||||
# corrupt block, so file become unaligned:
|
||||
# 712 Assert(header.compressed_size <= BLCKSZ);
|
||||
# 713
|
||||
# 714 read_len = fread(compressed_page.data, 1,
|
||||
# 715 MAXALIGN(header.compressed_size), in);
|
||||
# 716 if (read_len != MAXALIGN(header.compressed_size))
|
||||
# -> 717 elog(ERROR, "cannot read block %u of \"%s\" read %lu of %d",
|
||||
# 718 blknum, file->path, read_len, header.compressed_size);
|
||||
|
240
win32build.pl
240
win32build.pl
@ -1,240 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
use JSON;
|
||||
our $repack_version;
|
||||
our $pgdir;
|
||||
our $pgsrc;
|
||||
if (@ARGV!=2) {
|
||||
print STDERR "Usage $0 postgress-instalation-root pg-source-dir \n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
|
||||
our $liblist="";
|
||||
|
||||
|
||||
$pgdir = shift @ARGV;
|
||||
$pgsrc = shift @ARGV if @ARGV;
|
||||
|
||||
|
||||
our $arch = $ENV{'ARCH'} || "x64";
|
||||
$arch='Win32' if ($arch eq 'x86' || $arch eq 'X86');
|
||||
$arch='x64' if $arch eq 'X64';
|
||||
|
||||
$conffile = $pgsrc."/tools/msvc/config.pl";
|
||||
|
||||
|
||||
die 'Could not find config.pl'
|
||||
unless (-f $conffile);
|
||||
|
||||
our $config;
|
||||
do $conffile;
|
||||
|
||||
|
||||
if (! -d "$pgdir/bin" || !-d "$pgdir/include" || !-d "$pgdir/lib") {
|
||||
print STDERR "Directory $pgdir doesn't look like root of postgresql installation\n";
|
||||
exit 1;
|
||||
}
|
||||
our $includepath="";
|
||||
our $libpath="";
|
||||
our $libpath32="";
|
||||
AddProject();
|
||||
|
||||
print "\n\n";
|
||||
print $libpath."\n";
|
||||
print $includepath."\n";
|
||||
|
||||
# open F,"<","META.json" or die "Cannot open META.json: $!\n";
|
||||
# {
|
||||
# local $/ = undef;
|
||||
# $decoded = decode_json(<F>);
|
||||
# $repack_version= $decoded->{'version'};
|
||||
# }
|
||||
|
||||
# substitute new path in the project files
|
||||
|
||||
|
||||
|
||||
preprocess_project("./msvs/template.pg_probackup.vcxproj","./msvs/pg_probackup.vcxproj");
|
||||
|
||||
exit 0;
|
||||
|
||||
|
||||
sub preprocess_project {
|
||||
my $in = shift;
|
||||
my $out = shift;
|
||||
our $pgdir;
|
||||
our $adddir;
|
||||
my $libs;
|
||||
if (defined $adddir) {
|
||||
$libs ="$adddir;";
|
||||
} else{
|
||||
$libs ="";
|
||||
}
|
||||
open IN,"<",$in or die "Cannot open $in: $!\n";
|
||||
open OUT,">",$out or die "Cannot open $out: $!\n";
|
||||
|
||||
# $includepath .= ";";
|
||||
# $libpath .= ";";
|
||||
|
||||
while (<IN>) {
|
||||
s/\@PGROOT\@/$pgdir/g;
|
||||
s/\@ADDLIBS\@/$libpath/g;
|
||||
s/\@ADDLIBS32\@/$libpath32/g;
|
||||
s/\@PGSRC\@/$pgsrc/g;
|
||||
s/\@ADDINCLUDE\@/$includepath/g;
|
||||
|
||||
|
||||
print OUT $_;
|
||||
}
|
||||
close IN;
|
||||
close OUT;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
# my sub
|
||||
sub AddLibrary
|
||||
{
|
||||
$inc = shift;
|
||||
if ($libpath ne '')
|
||||
{
|
||||
$libpath .= ';';
|
||||
}
|
||||
$libpath .= $inc;
|
||||
if ($libpath32 ne '')
|
||||
{
|
||||
$libpath32 .= ';';
|
||||
}
|
||||
$libpath32 .= $inc;
|
||||
|
||||
}
|
||||
sub AddLibrary32
|
||||
{
|
||||
$inc = shift;
|
||||
if ($libpath32 ne '')
|
||||
{
|
||||
$libpath32 .= ';';
|
||||
}
|
||||
$libpath32 .= $inc;
|
||||
|
||||
}
|
||||
sub AddLibrary64
|
||||
{
|
||||
$inc = shift;
|
||||
if ($libpath ne '')
|
||||
{
|
||||
$libpath .= ';';
|
||||
}
|
||||
$libpath .= $inc;
|
||||
|
||||
}
|
||||
|
||||
sub AddIncludeDir
|
||||
{
|
||||
# my ($self, $inc) = @_;
|
||||
$inc = shift;
|
||||
if ($includepath ne '')
|
||||
{
|
||||
$includepath .= ';';
|
||||
}
|
||||
$includepath .= $inc;
|
||||
|
||||
}
|
||||
|
||||
sub AddProject
|
||||
{
|
||||
# my ($self, $name, $type, $folder, $initialdir) = @_;
|
||||
|
||||
if ($config->{zlib})
|
||||
{
|
||||
AddIncludeDir($config->{zlib} . '\include');
|
||||
AddLibrary($config->{zlib} . '\lib\zdll.lib');
|
||||
}
|
||||
if ($config->{openssl})
|
||||
{
|
||||
AddIncludeDir($config->{openssl} . '\include');
|
||||
if (-e "$config->{openssl}/lib/VC/ssleay32MD.lib")
|
||||
{
|
||||
AddLibrary(
|
||||
$config->{openssl} . '\lib\VC\ssleay32.lib', 1);
|
||||
AddLibrary(
|
||||
$config->{openssl} . '\lib\VC\libeay32.lib', 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
# We don't expect the config-specific library to be here,
|
||||
# so don't ask for it in last parameter
|
||||
AddLibrary(
|
||||
$config->{openssl} . '\lib\ssleay32.lib', 0);
|
||||
AddLibrary(
|
||||
$config->{openssl} . '\lib\libeay32.lib', 0);
|
||||
}
|
||||
}
|
||||
if ($config->{nls})
|
||||
{
|
||||
AddIncludeDir($config->{nls} . '\include');
|
||||
AddLibrary($config->{nls} . '\lib\libintl.lib');
|
||||
}
|
||||
if ($config->{gss})
|
||||
{
|
||||
AddIncludeDir($config->{gss} . '\inc\krb5');
|
||||
AddLibrary($config->{gss} . '\lib\i386\krb5_32.lib');
|
||||
AddLibrary($config->{gss} . '\lib\i386\comerr32.lib');
|
||||
AddLibrary($config->{gss} . '\lib\i386\gssapi32.lib');
|
||||
}
|
||||
if ($config->{iconv})
|
||||
{
|
||||
AddIncludeDir($config->{iconv} . '\include');
|
||||
AddLibrary($config->{iconv} . '\lib\iconv.lib');
|
||||
}
|
||||
if ($config->{icu})
|
||||
{
|
||||
AddIncludeDir($config->{icu} . '\include');
|
||||
AddLibrary32($config->{icu} . '\lib\icuin.lib');
|
||||
AddLibrary32($config->{icu} . '\lib\icuuc.lib');
|
||||
AddLibrary32($config->{icu} . '\lib\icudt.lib');
|
||||
AddLibrary64($config->{icu} . '\lib64\icuin.lib');
|
||||
AddLibrary64($config->{icu} . '\lib64\icuuc.lib');
|
||||
AddLibrary64($config->{icu} . '\lib64\icudt.lib');
|
||||
}
|
||||
if ($config->{xml})
|
||||
{
|
||||
AddIncludeDir($config->{xml} . '\include');
|
||||
AddIncludeDir($config->{xml} . '\include\libxml2');
|
||||
AddLibrary($config->{xml} . '\lib\libxml2.lib');
|
||||
}
|
||||
if ($config->{xslt})
|
||||
{
|
||||
AddIncludeDir($config->{xslt} . '\include');
|
||||
AddLibrary($config->{xslt} . '\lib\libxslt.lib');
|
||||
}
|
||||
if ($config->{libedit})
|
||||
{
|
||||
AddIncludeDir($config->{libedit} . '\include');
|
||||
# AddLibrary($config->{libedit} . "\\" .
|
||||
# ($arch eq 'x64'? 'lib64': 'lib32').'\edit.lib');
|
||||
AddLibrary32($config->{libedit} . '\\lib32\edit.lib');
|
||||
AddLibrary64($config->{libedit} . '\\lib64\edit.lib');
|
||||
|
||||
|
||||
}
|
||||
if ($config->{uuid})
|
||||
{
|
||||
AddIncludeDir($config->{uuid} . '\include');
|
||||
AddLibrary($config->{uuid} . '\lib\uuid.lib');
|
||||
}
|
||||
|
||||
if ($config->{zstd})
|
||||
{
|
||||
AddIncludeDir($config->{zstd});
|
||||
# AddLibrary($config->{zstd}. "\\".($arch eq 'x64'? "zstdlib_x64.lib" : "zstdlib_x86.lib"));
|
||||
AddLibrary32($config->{zstd}. "\\zstdlib_x86.lib");
|
||||
AddLibrary64($config->{zstd}. "\\zstdlib_x64.lib") ;
|
||||
}
|
||||
# return $proj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
240
win32build96.pl
240
win32build96.pl
@ -1,240 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
use JSON;
|
||||
our $repack_version;
|
||||
our $pgdir;
|
||||
our $pgsrc;
|
||||
if (@ARGV!=2) {
|
||||
print STDERR "Usage $0 postgress-instalation-root pg-source-dir \n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
|
||||
our $liblist="";
|
||||
|
||||
|
||||
$pgdir = shift @ARGV;
|
||||
$pgsrc = shift @ARGV if @ARGV;
|
||||
|
||||
|
||||
our $arch = $ENV{'ARCH'} || "x64";
|
||||
$arch='Win32' if ($arch eq 'x86' || $arch eq 'X86');
|
||||
$arch='x64' if $arch eq 'X64';
|
||||
|
||||
$conffile = $pgsrc."/tools/msvc/config.pl";
|
||||
|
||||
|
||||
die 'Could not find config.pl'
|
||||
unless (-f $conffile);
|
||||
|
||||
our $config;
|
||||
do $conffile;
|
||||
|
||||
|
||||
if (! -d "$pgdir/bin" || !-d "$pgdir/include" || !-d "$pgdir/lib") {
|
||||
print STDERR "Directory $pgdir doesn't look like root of postgresql installation\n";
|
||||
exit 1;
|
||||
}
|
||||
our $includepath="";
|
||||
our $libpath="";
|
||||
our $libpath32="";
|
||||
AddProject();
|
||||
|
||||
print "\n\n";
|
||||
print $libpath."\n";
|
||||
print $includepath."\n";
|
||||
|
||||
# open F,"<","META.json" or die "Cannot open META.json: $!\n";
|
||||
# {
|
||||
# local $/ = undef;
|
||||
# $decoded = decode_json(<F>);
|
||||
# $repack_version= $decoded->{'version'};
|
||||
# }
|
||||
|
||||
# substitute new path in the project files
|
||||
|
||||
|
||||
|
||||
preprocess_project("./msvs/template.pg_probackup96.vcxproj","./msvs/pg_probackup.vcxproj");
|
||||
|
||||
exit 0;
|
||||
|
||||
|
||||
sub preprocess_project {
|
||||
my $in = shift;
|
||||
my $out = shift;
|
||||
our $pgdir;
|
||||
our $adddir;
|
||||
my $libs;
|
||||
if (defined $adddir) {
|
||||
$libs ="$adddir;";
|
||||
} else{
|
||||
$libs ="";
|
||||
}
|
||||
open IN,"<",$in or die "Cannot open $in: $!\n";
|
||||
open OUT,">",$out or die "Cannot open $out: $!\n";
|
||||
|
||||
# $includepath .= ";";
|
||||
# $libpath .= ";";
|
||||
|
||||
while (<IN>) {
|
||||
s/\@PGROOT\@/$pgdir/g;
|
||||
s/\@ADDLIBS\@/$libpath/g;
|
||||
s/\@ADDLIBS32\@/$libpath32/g;
|
||||
s/\@PGSRC\@/$pgsrc/g;
|
||||
s/\@ADDINCLUDE\@/$includepath/g;
|
||||
|
||||
|
||||
print OUT $_;
|
||||
}
|
||||
close IN;
|
||||
close OUT;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
# my sub
|
||||
sub AddLibrary
|
||||
{
|
||||
$inc = shift;
|
||||
if ($libpath ne '')
|
||||
{
|
||||
$libpath .= ';';
|
||||
}
|
||||
$libpath .= $inc;
|
||||
if ($libpath32 ne '')
|
||||
{
|
||||
$libpath32 .= ';';
|
||||
}
|
||||
$libpath32 .= $inc;
|
||||
|
||||
}
|
||||
sub AddLibrary32
|
||||
{
|
||||
$inc = shift;
|
||||
if ($libpath32 ne '')
|
||||
{
|
||||
$libpath32 .= ';';
|
||||
}
|
||||
$libpath32 .= $inc;
|
||||
|
||||
}
|
||||
sub AddLibrary64
|
||||
{
|
||||
$inc = shift;
|
||||
if ($libpath ne '')
|
||||
{
|
||||
$libpath .= ';';
|
||||
}
|
||||
$libpath .= $inc;
|
||||
|
||||
}
|
||||
|
||||
sub AddIncludeDir
|
||||
{
|
||||
# my ($self, $inc) = @_;
|
||||
$inc = shift;
|
||||
if ($includepath ne '')
|
||||
{
|
||||
$includepath .= ';';
|
||||
}
|
||||
$includepath .= $inc;
|
||||
|
||||
}
|
||||
|
||||
sub AddProject
|
||||
{
|
||||
# my ($self, $name, $type, $folder, $initialdir) = @_;
|
||||
|
||||
if ($config->{zlib})
|
||||
{
|
||||
AddIncludeDir($config->{zlib} . '\include');
|
||||
AddLibrary($config->{zlib} . '\lib\zdll.lib');
|
||||
}
|
||||
if ($config->{openssl})
|
||||
{
|
||||
AddIncludeDir($config->{openssl} . '\include');
|
||||
if (-e "$config->{openssl}/lib/VC/ssleay32MD.lib")
|
||||
{
|
||||
AddLibrary(
|
||||
$config->{openssl} . '\lib\VC\ssleay32.lib', 1);
|
||||
AddLibrary(
|
||||
$config->{openssl} . '\lib\VC\libeay32.lib', 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
# We don't expect the config-specific library to be here,
|
||||
# so don't ask for it in last parameter
|
||||
AddLibrary(
|
||||
$config->{openssl} . '\lib\ssleay32.lib', 0);
|
||||
AddLibrary(
|
||||
$config->{openssl} . '\lib\libeay32.lib', 0);
|
||||
}
|
||||
}
|
||||
if ($config->{nls})
|
||||
{
|
||||
AddIncludeDir($config->{nls} . '\include');
|
||||
AddLibrary($config->{nls} . '\lib\libintl.lib');
|
||||
}
|
||||
if ($config->{gss})
|
||||
{
|
||||
AddIncludeDir($config->{gss} . '\inc\krb5');
|
||||
AddLibrary($config->{gss} . '\lib\i386\krb5_32.lib');
|
||||
AddLibrary($config->{gss} . '\lib\i386\comerr32.lib');
|
||||
AddLibrary($config->{gss} . '\lib\i386\gssapi32.lib');
|
||||
}
|
||||
if ($config->{iconv})
|
||||
{
|
||||
AddIncludeDir($config->{iconv} . '\include');
|
||||
AddLibrary($config->{iconv} . '\lib\iconv.lib');
|
||||
}
|
||||
if ($config->{icu})
|
||||
{
|
||||
AddIncludeDir($config->{icu} . '\include');
|
||||
AddLibrary32($config->{icu} . '\lib\icuin.lib');
|
||||
AddLibrary32($config->{icu} . '\lib\icuuc.lib');
|
||||
AddLibrary32($config->{icu} . '\lib\icudt.lib');
|
||||
AddLibrary64($config->{icu} . '\lib64\icuin.lib');
|
||||
AddLibrary64($config->{icu} . '\lib64\icuuc.lib');
|
||||
AddLibrary64($config->{icu} . '\lib64\icudt.lib');
|
||||
}
|
||||
if ($config->{xml})
|
||||
{
|
||||
AddIncludeDir($config->{xml} . '\include');
|
||||
AddIncludeDir($config->{xml} . '\include\libxml2');
|
||||
AddLibrary($config->{xml} . '\lib\libxml2.lib');
|
||||
}
|
||||
if ($config->{xslt})
|
||||
{
|
||||
AddIncludeDir($config->{xslt} . '\include');
|
||||
AddLibrary($config->{xslt} . '\lib\libxslt.lib');
|
||||
}
|
||||
if ($config->{libedit})
|
||||
{
|
||||
AddIncludeDir($config->{libedit} . '\include');
|
||||
# AddLibrary($config->{libedit} . "\\" .
|
||||
# ($arch eq 'x64'? 'lib64': 'lib32').'\edit.lib');
|
||||
AddLibrary32($config->{libedit} . '\\lib32\edit.lib');
|
||||
AddLibrary64($config->{libedit} . '\\lib64\edit.lib');
|
||||
|
||||
|
||||
}
|
||||
if ($config->{uuid})
|
||||
{
|
||||
AddIncludeDir($config->{uuid} . '\include');
|
||||
AddLibrary($config->{uuid} . '\lib\uuid.lib');
|
||||
}
|
||||
|
||||
if ($config->{zstd})
|
||||
{
|
||||
AddIncludeDir($config->{zstd});
|
||||
# AddLibrary($config->{zstd}. "\\".($arch eq 'x64'? "zstdlib_x64.lib" : "zstdlib_x86.lib"));
|
||||
AddLibrary32($config->{zstd}. "\\zstdlib_x86.lib");
|
||||
AddLibrary64($config->{zstd}. "\\zstdlib_x64.lib") ;
|
||||
}
|
||||
# return $proj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
219
win32build_2.pl
219
win32build_2.pl
@ -1,219 +0,0 @@
|
||||
#!/usr/bin/perl
|
||||
use JSON;
|
||||
our $repack_version;
|
||||
our $pgdir;
|
||||
our $pgsrc;
|
||||
if (@ARGV!=2) {
|
||||
print STDERR "Usage $0 postgress-instalation-root pg-source-dir \n";
|
||||
exit 1;
|
||||
}
|
||||
|
||||
|
||||
our $liblist="";
|
||||
|
||||
|
||||
$pgdir = shift @ARGV;
|
||||
$pgsrc = shift @ARGV if @ARGV;
|
||||
|
||||
|
||||
our $arch = $ENV{'ARCH'} || "x64";
|
||||
$arch='Win32' if ($arch eq 'x86' || $arch eq 'X86');
|
||||
$arch='x64' if $arch eq 'X64';
|
||||
|
||||
$conffile = $pgsrc."/tools/msvc/config.pl";
|
||||
|
||||
|
||||
die 'Could not find config.pl'
|
||||
unless (-f $conffile);
|
||||
|
||||
our $config;
|
||||
do $conffile;
|
||||
|
||||
|
||||
if (! -d "$pgdir/bin" || !-d "$pgdir/include" || !-d "$pgdir/lib") {
|
||||
print STDERR "Directory $pgdir doesn't look like root of postgresql installation\n";
|
||||
exit 1;
|
||||
}
|
||||
our $includepath="";
|
||||
our $libpath="";
|
||||
AddProject();
|
||||
|
||||
print "\n\n";
|
||||
print $libpath."\n";
|
||||
print $includepath."\n";
|
||||
|
||||
# open F,"<","META.json" or die "Cannot open META.json: $!\n";
|
||||
# {
|
||||
# local $/ = undef;
|
||||
# $decoded = decode_json(<F>);
|
||||
# $repack_version= $decoded->{'version'};
|
||||
# }
|
||||
|
||||
# substitute new path in the project files
|
||||
|
||||
|
||||
|
||||
preprocess_project("./msvs/template.pg_probackup_2.vcxproj","./msvs/pg_probackup.vcxproj");
|
||||
|
||||
exit 0;
|
||||
|
||||
|
||||
sub preprocess_project {
|
||||
my $in = shift;
|
||||
my $out = shift;
|
||||
our $pgdir;
|
||||
our $adddir;
|
||||
my $libs;
|
||||
if (defined $adddir) {
|
||||
$libs ="$adddir;";
|
||||
} else{
|
||||
$libs ="";
|
||||
}
|
||||
open IN,"<",$in or die "Cannot open $in: $!\n";
|
||||
open OUT,">",$out or die "Cannot open $out: $!\n";
|
||||
|
||||
# $includepath .= ";";
|
||||
# $libpath .= ";";
|
||||
|
||||
while (<IN>) {
|
||||
s/\@PGROOT\@/$pgdir/g;
|
||||
s/\@ADDLIBS\@/$libpath/g;
|
||||
s/\@PGSRC\@/$pgsrc/g;
|
||||
s/\@ADDINCLUDE\@/$includepath/g;
|
||||
|
||||
|
||||
print OUT $_;
|
||||
}
|
||||
close IN;
|
||||
close OUT;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
# my sub
|
||||
sub AddLibrary
|
||||
{
|
||||
$inc = shift;
|
||||
if ($libpath ne '')
|
||||
{
|
||||
$libpath .= ';';
|
||||
}
|
||||
$libpath .= $inc;
|
||||
|
||||
}
|
||||
sub AddIncludeDir
|
||||
{
|
||||
# my ($self, $inc) = @_;
|
||||
$inc = shift;
|
||||
if ($includepath ne '')
|
||||
{
|
||||
$includepath .= ';';
|
||||
}
|
||||
$includepath .= $inc;
|
||||
|
||||
}
|
||||
|
||||
sub AddProject
|
||||
{
|
||||
# my ($self, $name, $type, $folder, $initialdir) = @_;
|
||||
|
||||
if ($config->{zlib})
|
||||
{
|
||||
AddIncludeDir($config->{zlib} . '\include');
|
||||
AddLibrary($config->{zlib} . '\lib\zdll.lib');
|
||||
}
|
||||
if ($config->{openssl})
|
||||
{
|
||||
AddIncludeDir($config->{openssl} . '\include');
|
||||
if (-e "$config->{openssl}/lib/VC/ssleay32MD.lib")
|
||||
{
|
||||
AddLibrary(
|
||||
$config->{openssl} . '\lib\VC\ssleay32.lib', 1);
|
||||
AddLibrary(
|
||||
$config->{openssl} . '\lib\VC\libeay32.lib', 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
# We don't expect the config-specific library to be here,
|
||||
# so don't ask for it in last parameter
|
||||
AddLibrary(
|
||||
$config->{openssl} . '\lib\ssleay32.lib', 0);
|
||||
AddLibrary(
|
||||
$config->{openssl} . '\lib\libeay32.lib', 0);
|
||||
}
|
||||
}
|
||||
if ($config->{nls})
|
||||
{
|
||||
AddIncludeDir($config->{nls} . '\include');
|
||||
AddLibrary($config->{nls} . '\lib\libintl.lib');
|
||||
}
|
||||
if ($config->{gss})
|
||||
{
|
||||
AddIncludeDir($config->{gss} . '\inc\krb5');
|
||||
AddLibrary($config->{gss} . '\lib\i386\krb5_32.lib');
|
||||
AddLibrary($config->{gss} . '\lib\i386\comerr32.lib');
|
||||
AddLibrary($config->{gss} . '\lib\i386\gssapi32.lib');
|
||||
}
|
||||
if ($config->{iconv})
|
||||
{
|
||||
AddIncludeDir($config->{iconv} . '\include');
|
||||
AddLibrary($config->{iconv} . '\lib\iconv.lib');
|
||||
}
|
||||
if ($config->{icu})
|
||||
{
|
||||
AddIncludeDir($config->{icu} . '\include');
|
||||
if ($arch eq 'Win32')
|
||||
{
|
||||
AddLibrary($config->{icu} . '\lib\icuin.lib');
|
||||
AddLibrary($config->{icu} . '\lib\icuuc.lib');
|
||||
AddLibrary($config->{icu} . '\lib\icudt.lib');
|
||||
}
|
||||
else
|
||||
{
|
||||
AddLibrary($config->{icu} . '\lib64\icuin.lib');
|
||||
AddLibrary($config->{icu} . '\lib64\icuuc.lib');
|
||||
AddLibrary($config->{icu} . '\lib64\icudt.lib');
|
||||
}
|
||||
}
|
||||
if ($config->{xml})
|
||||
{
|
||||
AddIncludeDir($config->{xml} . '\include');
|
||||
AddIncludeDir($config->{xml} . '\include\libxml2');
|
||||
AddLibrary($config->{xml} . '\lib\libxml2.lib');
|
||||
}
|
||||
if ($config->{xslt})
|
||||
{
|
||||
AddIncludeDir($config->{xslt} . '\include');
|
||||
AddLibrary($config->{xslt} . '\lib\libxslt.lib');
|
||||
}
|
||||
if ($config->{libedit})
|
||||
{
|
||||
AddIncludeDir($config->{libedit} . '\include');
|
||||
AddLibrary($config->{libedit} . "\\" .
|
||||
($arch eq 'x64'? 'lib64': 'lib32').'\edit.lib');
|
||||
}
|
||||
if ($config->{uuid})
|
||||
{
|
||||
AddIncludeDir($config->{uuid} . '\include');
|
||||
AddLibrary($config->{uuid} . '\lib\uuid.lib');
|
||||
}
|
||||
if ($config->{libedit})
|
||||
{
|
||||
AddIncludeDir($config->{libedit} . '\include');
|
||||
AddLibrary($config->{libedit} . "\\" .
|
||||
($arch eq 'x64'? 'lib64': 'lib32').'\edit.lib');
|
||||
}
|
||||
if ($config->{zstd})
|
||||
{
|
||||
AddIncludeDir($config->{zstd});
|
||||
AddLibrary($config->{zstd}. "\\".
|
||||
($arch eq 'x64'? "zstdlib_x64.lib" : "zstdlib_x86.lib")
|
||||
);
|
||||
}
|
||||
# return $proj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user