#include "postgres_fe.h"
#include <unistd.h>
#include <sys/stat.h>
#include "access/xlog_internal.h"
#include "common/archive.h"
#include "common/logging.h"
#include "fe_utils/archive.h"
Go to the source code of this file.
|
int | RestoreArchivedFile (const char *path, const char *xlogfname, off_t expectedSize, const char *restoreCommand) |
|
◆ RestoreArchivedFile()
int RestoreArchivedFile |
( |
const char * |
path, |
|
|
const char * |
xlogfname, |
|
|
off_t |
expectedSize, |
|
|
const char * |
restoreCommand |
|
) |
| |
Definition at line 39 of file archive.c.
References BuildRestoreCommand(), MAXPGPATH, pfree(), PG_BINARY, pg_log_error, pg_log_fatal, snprintf, stat::st_size, stat, wait_result_is_any_signal(), wait_result_to_str(), and XLOGDIR.
51 if (xlogRestoreCmd == NULL)
53 pg_log_fatal(
"cannot use restore_command with %%r placeholder");
61 rc = system(xlogRestoreCmd);
62 pfree(xlogRestoreCmd);
70 if (
stat(xlogpath, &stat_buf) == 0)
72 if (expectedSize > 0 && stat_buf.st_size != expectedSize)
74 pg_log_fatal(
"unexpected file size for \"%s\": %lld instead of %lld",
75 xlogfname, (
long long int) stat_buf.st_size,
76 (
long long int) expectedSize);
81 int xlogfd = open(xlogpath, O_RDONLY |
PG_BINARY, 0);
85 pg_log_fatal(
"could not open file \"%s\" restored from archive: %m",
121 pg_log_error(
"could not restore file \"%s\" from archive",
char * BuildRestoreCommand(const char *restoreCommand, const char *xlogpath, const char *xlogfname, const char *lastRestartPointFname)
#define pg_log_error(...)
char * wait_result_to_str(int exitstatus)
void pfree(void *pointer)
bool wait_result_is_any_signal(int exit_status, bool include_command_not_found)
#define pg_log_fatal(...)