1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-05-31 22:49:46 +02:00

Improved error message when the restore command detects the presence of postmaster.pid.

Suggested by Yogesh Sharma.
This commit is contained in:
David Steele 2017-04-12 09:53:07 -04:00
parent b0119914d4
commit f5f8d51366
4 changed files with 29 additions and 1 deletions

View File

@ -196,6 +196,14 @@
<p>Do not set timestamps of files in the backup directories to match timestamps in the cluster directory. This was originally done to enable backup resume, but that process is now implemented with checksums.</p>
</release-item>
<release-item>
<release-item-contributor-list>
<release-item-ideator id="sharma.yogesh"/>
</release-item-contributor-list>
<p>Improved error message when the <cmd>restore</cmd> command detects the presence of <file>postmaster.pid</file>.</p>
</release-item>
<release-item>
<p>The <cmd>backup</cmd> and <cmd>restore</cmd> commands no longer copy via temp files. In both cases the files are checksummed on resume so there's no danger of partial copies.</p>
</release-item>

View File

@ -1048,7 +1048,11 @@ sub process
# Make sure that Postgres is not running
if ($self->{oFile}->exists(PATH_DB_ABSOLUTE, $self->{strDbClusterPath} . '/' . DB_FILE_POSTMASTERPID))
{
confess &log(ERROR, 'unable to restore while Postgres is running', ERROR_POSTMASTER_RUNNING);
confess &log(ERROR,
"unable to restore while PostgreSQL is running\n" .
"HINT: presence of '" . DB_FILE_POSTMASTERPID . "' in '$self->{strDbClusterPath}' indicates PostgreSQL is running.\n" .
"HINT: remove '" . DB_FILE_POSTMASTERPID . "' only if PostgreSQL is not running.",
ERROR_POSTMASTER_RUNNING);
}
# If the restore will be destructive attempt to verify that $PGDATA is valid

View File

@ -1151,6 +1151,13 @@ P00 WARN: backup group for pg_data/base/16384/PG_VERSION was not mapped to a n
P00 WARN: backup user for pg_data/base/1/PG_VERSION was not mapped to a name, set to [USER-1]
P00 ERROR: [115]: cannot restore file '[TEST_PATH]/db-master/db/pg_config/postgresql.conf' that already exists - try using --delta if this is what you intended
restore, backup '[BACKUP-FULL-2]', expect exit 113 - error on postmaster.pid exists (db-master host)
> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --set=[BACKUP-FULL-2] --log-level-console=warn --stanza=db restore
------------------------------------------------------------------------------------------------------------------------------------
P00 ERROR: [113]: unable to restore while PostgreSQL is running
HINT: presence of 'postmaster.pid' in '[TEST_PATH]/db-master/db/base' indicates PostgreSQL is running.
HINT: remove 'postmaster.pid' only if PostgreSQL is not running.
restore delta, backup '[BACKUP-FULL-2]' - restore all links --link-all and mapping (db-master host)
> [CONTAINER-EXEC] db-master [BACKREST-BIN] --config=[TEST_PATH]/db-master/pgbackrest.conf --delta --set=[BACKUP-FULL-2] --log-level-console=detail --link-map=pg_stat=../pg_stat --link-all --stanza=db restore
------------------------------------------------------------------------------------------------------------------------------------

View File

@ -543,6 +543,15 @@ sub run
$strFullBackup, \%oManifest, undef, $bDelta, $bForce, undef, undef, undef, undef, undef, undef,
'error on existing linked file', ERROR_PATH_NOT_EMPTY, '--log-level-console=warn --link-all');
# Error when postmaster.pid is present
executeTest('touch ' . $oHostDbMaster->dbBasePath() . qw(/) . DB_FILE_POSTMASTERPID);
$oHostDbMaster->restore(
$strFullBackup, \%oManifest, undef, $bDelta, $bForce, undef, undef, undef, undef, undef, undef,
'error on postmaster.pid exists', ERROR_POSTMASTER_RUNNING, '--log-level-console=warn');
executeTest('rm ' . $oHostDbMaster->dbBasePath() . qw(/) . DB_FILE_POSTMASTERPID);
# Now a combination of remapping
$bDelta = true;