You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-09-16 09:06:18 +02:00
archive-get function is working.
Added option to force checkpoint at backup start.
This commit is contained in:
21
README.md
21
README.md
@@ -3,21 +3,22 @@ pg_backrest
|
||||
|
||||
Simple Postgres Backup and Restore
|
||||
|
||||
release notes
|
||||
=============
|
||||
|
||||
v0.15: Added archive-get [PLANNED FUNCTIONALITY FOR THIS RELEASE]
|
||||
|
||||
* Added archive-get functionality to aid in restores.
|
||||
planned for next release
|
||||
========================
|
||||
|
||||
* Default restore.conf is written to each backup.
|
||||
|
||||
* Added option to force a checkpoint when starting the backup.
|
||||
|
||||
* Now throws ERROR when unable to get lock during backup or export.
|
||||
|
||||
* Able to set timeout on ssh connection in config file.
|
||||
|
||||
release notes
|
||||
=============
|
||||
|
||||
v0.15: Added archive-get
|
||||
|
||||
* Added archive-get functionality to aid in restores.
|
||||
|
||||
* Added option to force a checkpoint when starting the backup (start_fast=y).
|
||||
|
||||
-------------
|
||||
|
||||
v0.11: Minor fixes
|
||||
|
@@ -18,6 +18,7 @@ path=/Users/backrest/test
|
||||
archive-required=y
|
||||
thread-max=2
|
||||
thread-timeout=900
|
||||
start_fast=y
|
||||
|
||||
[global:archive]
|
||||
path=/Users/dsteele/test
|
||||
|
@@ -55,6 +55,7 @@ use constant
|
||||
CONFIG_KEY_HARDLINK => "hardlink",
|
||||
CONFIG_KEY_ARCHIVE_REQUIRED => "archive-required",
|
||||
CONFIG_KEY_ARCHIVE_MAX_MB => "archive-max-mb",
|
||||
CONFIG_KEY_START_FAST => "start_fast",
|
||||
|
||||
CONFIG_KEY_LEVEL_FILE => "level-file",
|
||||
CONFIG_KEY_LEVEL_CONSOLE => "level-console",
|
||||
@@ -535,7 +536,8 @@ if ($strOperation eq OP_BACKUP)
|
||||
exit 0
|
||||
}
|
||||
|
||||
backup(config_load(CONFIG_SECTION_STANZA, CONFIG_KEY_PATH));
|
||||
backup(config_load(CONFIG_SECTION_STANZA, CONFIG_KEY_PATH),
|
||||
config_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_START_FAST, true, "n") eq "y" ? true : false);
|
||||
|
||||
$strOperation = OP_EXPIRE;
|
||||
|
||||
|
@@ -22,7 +22,8 @@ use pg_backrest_db;
|
||||
|
||||
use Exporter qw(import);
|
||||
|
||||
our @EXPORT = qw(backup_init backup_thread_kill archive_push archive_pull archive_compress backup backup_expire archive_list_get);
|
||||
our @EXPORT = qw(backup_init backup_thread_kill archive_push archive_pull archive_get archive_compress
|
||||
backup backup_expire archive_list_get);
|
||||
|
||||
my $oDb;
|
||||
my $oFile;
|
||||
@@ -211,6 +212,29 @@ sub backup_thread_complete
|
||||
return true;
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
# ARCHIVE_GET
|
||||
####################################################################################################################################
|
||||
sub archive_get
|
||||
{
|
||||
my $strSourceArchive = shift;
|
||||
my $strDestinationFile = shift;
|
||||
|
||||
my $strArchivePath = dirname($oFile->path_get(PATH_BACKUP_ARCHIVE, $strSourceArchive));
|
||||
|
||||
my @stryArchiveFile = $oFile->file_list_get(PATH_BACKUP_ABSOLUTE, $strArchivePath,
|
||||
"^${strSourceArchive}(-[0-f]+){0,1}(\\.$oFile->{strCompressExtension}){0,1}\$");
|
||||
|
||||
if (scalar @stryArchiveFile != 1)
|
||||
{
|
||||
confess &log(ERROR, (scalar @stryArchiveFile) . " archive file(s) found for ${strSourceArchive}");
|
||||
}
|
||||
|
||||
&log(DEBUG, "archive_get: cp ${stryArchiveFile[0]} ${strDestinationFile}");
|
||||
|
||||
$oFile->file_copy(PATH_BACKUP_ARCHIVE, $stryArchiveFile[0], PATH_DB_ABSOLUTE, $strDestinationFile);
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
# ARCHIVE_PUSH
|
||||
####################################################################################################################################
|
||||
@@ -1192,6 +1216,7 @@ sub backup_file_thread
|
||||
sub backup
|
||||
{
|
||||
my $strDbClusterPath = shift;
|
||||
my $bStartFast = shift;
|
||||
|
||||
# Not supporting remote backup hosts yet
|
||||
if ($oFile->is_remote(PATH_BACKUP))
|
||||
@@ -1260,7 +1285,7 @@ sub backup
|
||||
my %oBackupManifest;
|
||||
${oBackupManifest}{backup}{label} = $strBackupPath;
|
||||
|
||||
my $strArchiveStart = $oDb->backup_start($strBackupPath);
|
||||
my $strArchiveStart = $oDb->backup_start($strBackupPath, $bStartFast);
|
||||
${oBackupManifest}{backup}{"archive-start"} = $strArchiveStart;
|
||||
|
||||
&log(INFO, 'archive start: ' . ${oBackupManifest}{backup}{"archive-start"});
|
||||
|
@@ -126,9 +126,11 @@ sub backup_start
|
||||
{
|
||||
my $self = shift;
|
||||
my $strLabel = shift;
|
||||
my $bStartFast = shift;
|
||||
|
||||
return trim($self->psql_execute("set client_min_messages = 'warning';" .
|
||||
"copy (select pg_xlogfile_name(xlog) from pg_start_backup('${strLabel}') as xlog) to stdout"));
|
||||
"copy (select pg_xlogfile_name(xlog) from pg_start_backup('${strLabel}'" .
|
||||
($bStartFast ? ", true" : "") . ") as xlog) to stdout"));
|
||||
}
|
||||
|
||||
####################################################################################################################################
|
||||
|
@@ -170,7 +170,7 @@ sub path_get
|
||||
my $bTemp = shift; # Return the temp file for this path type - only some types have temp files
|
||||
|
||||
# Only allow temp files for PATH_BACKUP_ARCHIVE and PATH_BACKUP_TMP
|
||||
if (defined($bTemp) && $bTemp && !($strType eq PATH_BACKUP_ARCHIVE || $strType eq PATH_BACKUP_TMP))
|
||||
if (defined($bTemp) && $bTemp && !($strType eq PATH_BACKUP_ARCHIVE || $strType eq PATH_BACKUP_TMP || $strType eq PATH_DB_ABSOLUTE))
|
||||
{
|
||||
confess &log(ASSERT, "temp file not supported on path " . $strType);
|
||||
}
|
||||
@@ -178,6 +178,11 @@ sub path_get
|
||||
# Get absolute db path
|
||||
if ($strType eq PATH_DB_ABSOLUTE)
|
||||
{
|
||||
if (defined($bTemp) && $bTemp)
|
||||
{
|
||||
return $strFile . ".backrest.tmp";
|
||||
}
|
||||
|
||||
return $strFile;
|
||||
}
|
||||
|
||||
@@ -790,12 +795,6 @@ sub file_list_get
|
||||
# Split the files into an array
|
||||
my @stryFileList = grep(/$strExpression/i, split(/\n/, $strFileList));
|
||||
|
||||
# If nothing was found return undef
|
||||
# if (undef(@stryFileList) || scalar @stryFileList == 0)
|
||||
# {
|
||||
# return undef;
|
||||
# }
|
||||
|
||||
# Return the array in reverse order if specified
|
||||
if (defined($strSortOrder) && $strSortOrder eq "reverse")
|
||||
{
|
||||
|
Reference in New Issue
Block a user