mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-16 10:20:02 +02:00
18fd25233b
* The repo-path option now always refers to the repository where backups and archive are stored, whether local or remote, so the repo-remote-path option has been removed. The new spool-path option can be used to define a location for queueing WAL segments when archiving asynchronously. Otherwise, a local repository is no longer required. * Implemented a new config format which should be far simpler to use. See the User Guide and Configuration Reference for details but for a simple configuration all options can now be placed in the stanza section. Options that are shared between stanzas can be placed in the [global] section. More complex configurations can still make use of command sections though this should be a rare use case. * The default configuration filename is now pgbackrest.conf instead of pg_backrest.conf. This was done for consistency with other naming changes but also to prevent old config files from being loaded accidentally. * The default repository name was changed from /var/lib/backup to /var/lib/pgbackrest. * Lock files are now stored in /tmp/pgbackrest by default. These days /run/pgbackrest would be the preferred location but that would require init scripts which are not part of this release. The lock-path option can be used to configure the lock directory. * Log files are now stored in /var/log/pgbackrest by default and no longer have the date appended so they can be managed with logrotate. The log-path option can be used to configure the lock directory. * Executable filename changed from pg_backrest to pgbackrest.
128 lines
5.3 KiB
Perl
Executable File
128 lines
5.3 KiB
Perl
Executable File
####################################################################################################################################
|
|
# CompareTest.pm - Performance comparison tests between rsync and backrest
|
|
####################################################################################################################################
|
|
package pgBackRestTest::CompareTest;
|
|
|
|
####################################################################################################################################
|
|
# Perl includes
|
|
####################################################################################################################################
|
|
use strict;
|
|
use warnings FATAL => qw(all);
|
|
use Carp qw(confess);
|
|
|
|
use Exporter qw(import);
|
|
use File::Basename qw(dirname);
|
|
use File::stat;
|
|
use Time::HiRes qw(gettimeofday);
|
|
|
|
use lib dirname($0) . '/../lib';
|
|
use pgBackRest::Common::Log;
|
|
|
|
use pgBackRestTest::BackupTest;
|
|
use pgBackRestTest::CommonTest;
|
|
|
|
####################################################################################################################################
|
|
# Exports
|
|
####################################################################################################################################
|
|
our @EXPORT = qw(BackRestTestCompare_Test);
|
|
|
|
####################################################################################################################################
|
|
# BackRestTestCompare_BuildDb
|
|
####################################################################################################################################
|
|
sub BackRestTestCompare_BuildDb
|
|
{
|
|
my $iTableTotal = shift;
|
|
my $iTableSize = shift;
|
|
|
|
&log(INFO, "build database: " . fileSizeFormat($iTableTotal * $iTableSize * 1024 * 1024));
|
|
|
|
for (my $iTableIdx = 0; $iTableIdx < $iTableTotal; $iTableIdx++)
|
|
{
|
|
my $strSourceFile = BackRestTestCommon_DataPathGet() . "/test.table.bin";
|
|
my $strTableFile = BackRestTestCommon_DbCommonPathGet() . "/test-${iTableIdx}";
|
|
|
|
for (my $iTableSizeIdx = 0; $iTableSizeIdx < $iTableSize; $iTableSizeIdx++)
|
|
{
|
|
executeTest("cat ${strSourceFile} >> ${strTableFile}");
|
|
}
|
|
}
|
|
}
|
|
|
|
####################################################################################################################################
|
|
# BackRestTestCompare_Test
|
|
####################################################################################################################################
|
|
sub BackRestTestCompare_Test
|
|
{
|
|
my $strTest = shift;
|
|
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
|
# Test rsync
|
|
#-------------------------------------------------------------------------------------------------------------------------------
|
|
if ($strTest eq 'all' || $strTest eq 'rsync')
|
|
{
|
|
my $iRun = 0;
|
|
my $bRemote = false;
|
|
|
|
&log(INFO, "Test rsync\n");
|
|
|
|
# Increment the run, log, and decide whether this unit test should be run
|
|
if (!BackRestTestCommon_Run(++$iRun,
|
|
"rmt ${bRemote}")) {next}
|
|
|
|
# Create the cluster and paths
|
|
BackRestTestBackup_Create($bRemote, false);
|
|
BackRestTestCommon_PathCreate(BackRestTestCommon_DbCommonPathGet() . '/pg_tblspc');
|
|
|
|
BackRestTestCompare_BuildDb(48, 10);
|
|
executeTest('sync');
|
|
|
|
for (my $bRemote = true; $bRemote <= true; $bRemote++)
|
|
{
|
|
for (my $bRsync = true; $bRsync >= false; $bRsync--)
|
|
{
|
|
my $strCommand;
|
|
BackRestTestCommon_CreateRepo($bRemote);
|
|
|
|
&log(INFO, ($bRsync ? 'rsync' : 'backrest') . " test");
|
|
|
|
if ($bRsync)
|
|
{
|
|
$strCommand = 'rsync --compress-level=6 -zvlhprtogHS --delete ' .
|
|
($bRemote ? BackRestTestCommon_UserGet . '@' . BackRestTestCommon_HostGet . ':' : '') .
|
|
BackRestTestCommon_DbCommonPathGet() . '/ ' . BackRestTestCommon_RepoPathGet() . ';' .
|
|
'gzip -r "' . BackRestTestCommon_RepoPathGet() . '"';
|
|
}
|
|
else
|
|
{
|
|
$strCommand = BackRestTestCommon_CommandMainGet() .
|
|
' --stanza=main' .
|
|
($bRemote ? ' "--db-host=' . BackRestTestCommon_HostGet . '"' .
|
|
' "--db-user=' . BackRestTestCommon_UserGet . '"' : '') .
|
|
# ' --log-level-file=debug' .
|
|
' --no-start-stop' .
|
|
# ' --no-compress' .
|
|
' --thread-max=4' .
|
|
' "--db-path=' . BackRestTestCommon_DbCommonPathGet() . '"' .
|
|
' "--repo-path=' . BackRestTestCommon_RepoPathGet() . '"' .
|
|
' --type=full backup';
|
|
}
|
|
|
|
my $fTimeBegin = gettimeofday();
|
|
executeTest($strCommand, $bRemote);
|
|
executeTest('sync');
|
|
my $fTimeEnd = gettimeofday();
|
|
|
|
&log(INFO, " time = " . (int(($fTimeEnd - $fTimeBegin) * 100) / 100));
|
|
}
|
|
}
|
|
|
|
if (BackRestTestCommon_Cleanup())
|
|
{
|
|
&log(INFO, 'cleanup');
|
|
BackRestTestBackup_Drop();
|
|
}
|
|
}
|
|
}
|
|
|
|
1;
|