1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2024-11-24 08:52:38 +02:00

Sanitize logging facility

--debug and --verbose had actually the same meaning as they were aimed
at giving to the user information regarding how the process is running,
hence both options are merged into --verbose and use elog(LOG) to decide
if a given message should be printed out depending on the verbosity of
the call. This makes a couple of routines more readable as they do not
depend on any boolean checks.

The "_()" have been removed from the code, those are aimed at being used
for translation but having them mandatorily in each log message is just
useless noise. If needed, pgut.c should be updated in consequence to
have a more portable facility.

At the same time this commit takes care of putting into correct shape
some code paths more in-line with PostgreSQL policy. There are surely
more of this kind of ugly stuff but at this stage things are more simple
and more manageable.
This commit is contained in:
Michael Paquier 2016-01-14 16:36:39 +09:00
parent 3ac6d13329
commit f94c5ab447
18 changed files with 300 additions and 337 deletions

160
backup.c
View File

@ -78,9 +78,9 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
/* Block backup operations on a standby */
if (pg_is_standby())
elog(ERROR_SYSTEM, _("Backup cannot run on a standby."));
elog(ERROR_SYSTEM, "Backup cannot run on a standby.");
elog(INFO, _("database backup start"));
elog(INFO, "database backup start");
/* Initialize size summary */
current.data_bytes = 0;
@ -102,9 +102,9 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
prev_backup = catalog_get_last_data_backup(backup_list, current.tli);
if (prev_backup == NULL)
elog(ERROR_SYSTEM, _("Valid full backup not found for "
elog(ERROR_SYSTEM, "Valid full backup not found for "
"differential backup. Either create a full backup "
"or validate existing one."));
"or validate existing one.");
}
/* notify start of backup to PostgreSQL server */
@ -121,10 +121,9 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
/* Leave if no backup file */
if (!has_backup_label)
{
if (verbose)
printf(_("backup_label does not exist, stop backup\n"));
elog(LOG, "backup_label does not exist, stopping backup");
pg_stop_backup(NULL);
elog(ERROR_SYSTEM, _("backup_label does not exist in PGDATA."));
elog(ERROR_SYSTEM, "backup_label does not exist in PGDATA.");
}
/*
@ -139,12 +138,12 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
pgBackupGetPath(&current, path, lengthof(path), MKDIRS_SH_FILE);
fp = fopen(path, "wt");
if (fp == NULL)
elog(ERROR_SYSTEM, _("can't open make directory script \"%s\": %s"),
elog(ERROR_SYSTEM, "can't open make directory script \"%s\": %s",
path, strerror(errno));
dir_print_mkdirs_sh(fp, files, pgdata);
fclose(fp);
if (chmod(path, DIR_PERMISSION) == -1)
elog(ERROR_SYSTEM, _("can't change mode of \"%s\": %s"), path,
elog(ERROR_SYSTEM, "can't change mode of \"%s\": %s", path,
strerror(errno));
}
@ -171,7 +170,7 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
* Do backup only pages having larger LSN than previous backup.
*/
lsn = &prev_backup->start_lsn;
elog(LOG, _("backup only the page that there was of the update from LSN(%X/%08X).\n"),
elog(LOG, "backup only the page that there was of the update from LSN(%X/%08X)",
(uint32) (*lsn >> 32), (uint32) *lsn);
}
@ -244,7 +243,7 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
* so snapshot-script output the tablespace name that not exist.
*/
if (parray_num(tblspc_list) > 0)
elog(ERROR_SYSTEM, _("snapshot-script output the name of tablespace that not exist"));
elog(ERROR_SYSTEM, "snapshot-script output the name of tablespace that not exist");
/* clear array */
parray_walk(tblspc_list, free);
@ -274,17 +273,14 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
* it doesn't use former value
*/
if ((spcname = strtok(item, "=")) == NULL || (mp = strtok(NULL, "\0")) == NULL)
elog(ERROR_SYSTEM, _("snapshot-script output illegal format: %s"), item);
elog(ERROR_SYSTEM, "snapshot-script output illegal format: %s", item);
if (verbose)
{
printf(_("========================================\n"));
printf(_("backup files from snapshot: \"%s\"\n"), spcname);
}
elog(LOG, "========================================");
elog(LOG, "backup files from snapshot: \"%s\"", spcname);
/* tablespace storage directory not exist */
if (!dirExists(mp))
elog(ERROR_SYSTEM, _("tablespace storage directory doesn't exist: %s"), mp);
elog(ERROR_SYSTEM, "tablespace storage directory doesn't exist: %s", mp);
/*
* create the previous backup file list to take differential backup
@ -354,7 +350,7 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
* so snapshot-script output the tablespace name that not exist.
*/
if (parray_num(tblspcmp_list) > 0)
elog(ERROR_SYSTEM, _("snapshot-script output the name of tablespace that not exist"));
elog(ERROR_SYSTEM, "snapshot-script output the name of tablespace that not exist");
/* clear array */
parray_walk(tblspcmp_list, free);
@ -401,12 +397,9 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
current.data_bytes += file->size;
}
if (verbose)
{
printf(_("database backup completed(Backup: " INT64_FORMAT ")\n"),
current.data_bytes);
printf(_("========================================\n"));
}
elog(LOG, "database backup completed(Backup: " INT64_FORMAT ")",
current.data_bytes);
elog(LOG, "========================================");
return files;
}
@ -425,13 +418,13 @@ do_backup(pgBackupOption bkupopt)
/* PGDATA and BACKUP_MODE are always required */
if (pgdata == NULL)
elog(ERROR_ARGS, _("Required parameter not specified: PGDATA "
"(-D, --pgdata)"));
elog(ERROR_ARGS, "Required parameter not specified: PGDATA "
"(-D, --pgdata)");
/* A backup mode is needed */
if (current.backup_mode == BACKUP_MODE_INVALID)
elog(ERROR_ARGS, _("Required parameter not specified: BACKUP_MODE "
"(-b, --backup-mode)"));
elog(ERROR_ARGS, "Required parameter not specified: BACKUP_MODE "
"(-b, --backup-mode)");
/* Confirm data block size and xlog block size are compatible */
check_server_version();
@ -440,22 +433,20 @@ do_backup(pgBackupOption bkupopt)
in_backup = true;
/* show configuration actually used */
elog(LOG, "========================================");
elog(LOG, "backup start");
elog(LOG, "----------------------------------------");
if (verbose)
{
printf(_("========================================\n"));
printf(_("backup start\n"));
printf(_("----------------------------------------\n"));
pgBackupWriteConfigSection(stderr, &current);
printf(_("----------------------------------------\n"));
}
elog(LOG, "----------------------------------------");
/* get exclusive lock of backup catalog */
ret = catalog_lock();
if (ret == -1)
elog(ERROR_SYSTEM, _("can't lock backup catalog."));
elog(ERROR_SYSTEM, "cannot lock backup catalog");
else if (ret == 1)
elog(ERROR_ALREADY_RUNNING,
_("another pg_arman is running, skip this backup."));
"another pg_arman is running, skipping this backup");
/* initialize backup result */
current.status = BACKUP_STATUS_RUNNING;
@ -474,16 +465,15 @@ do_backup(pgBackupOption bkupopt)
if (!check)
{
if (pgBackupCreateDir(&current))
elog(ERROR_SYSTEM, _("can't create backup directory."));
elog(ERROR_SYSTEM, "cannot create backup directory");
pgBackupWriteIni(&current);
}
if (verbose)
printf(_("backup destination is initialized.\n"));
elog(LOG, "backup destination is initialized");
/* get list of backups already taken */
backup_list = catalog_get_backup_list(NULL);
if (!backup_list)
elog(ERROR_SYSTEM, _("can't process any more."));
elog(ERROR_SYSTEM, "cannot process any more");
/* set the error processing function for the backup process */
pgut_atexit_push(backup_cleanup, NULL);
@ -509,12 +499,12 @@ do_backup(pgBackupOption bkupopt)
total_read += current.data_bytes;
if (total_read == 0)
printf(_("nothing to backup\n"));
elog(LOG, "nothing to backup");
else
printf(_("all backup completed(read: " INT64_FORMAT " write: "
INT64_FORMAT ")\n"),
total_read, current.data_bytes);
printf(_("========================================\n"));
elog(LOG, "all backup completed(read: " INT64_FORMAT " write: "
INT64_FORMAT ")",
total_read, current.data_bytes);
elog(LOG, "========================================");
}
@ -553,7 +543,7 @@ check_server_version(void)
server_version = PQserverVersion(connection);
if (server_version != PG_VERSION_NUM)
elog(ERROR_PG_INCOMPATIBLE,
_("server version is %d.%d.%d, must be %s or higher."),
"server version is %d.%d.%d, must be %s or higher.",
server_version / 10000,
(server_version / 100) % 100,
server_version % 100, PG_MAJORVERSION);
@ -575,13 +565,13 @@ confirm_block_size(const char *name, int blcksz)
res = execute("SELECT current_setting($1)", 1, &name);
if (PQntuples(res) != 1 || PQnfields(res) != 1)
elog(ERROR_PG_COMMAND, _("can't get %s: %s"),
elog(ERROR_PG_COMMAND, "cannot get %s: %s",
name, PQerrorMessage(connection));
block_size = strtol(PQgetvalue(res, 0, 0), &endp, 10);
PQclear(res);
if ((endp && *endp) || block_size != blcksz)
elog(ERROR_PG_INCOMPATIBLE,
_("%s(%d) is not compatible(%d expected)"),
"%s(%d) is not compatible(%d expected)",
name, block_size, blcksz);
}
@ -636,7 +626,7 @@ wait_for_archive(pgBackup *backup, const char *sql)
{
backup->tli = tli;
backup->stop_lsn = lsn;
elog(LOG, _("%s(): tli=%X lsn=%X/%08X"),
elog(LOG, "%s(): tli=%X lsn=%X/%08X",
__FUNCTION__, backup->tli,
(uint32) (backup->stop_lsn >> 32),
(uint32) backup->stop_lsn);
@ -649,12 +639,13 @@ wait_for_archive(pgBackup *backup, const char *sql)
snprintf(ready_path, lengthof(ready_path),
"%s/pg_xlog/archive_status/%s.ready", pgdata,
file_name);
elog(LOG, "%s() wait for %s\n", __FUNCTION__, ready_path);
elog(LOG, "%s() wait for %s", __FUNCTION__, ready_path);
PQclear(res);
res = execute(TXID_CURRENT_SQL, 0, NULL);
if(backup != NULL){
if (backup != NULL)
{
get_xid(res, &backup->recovery_xid);
backup->recovery_time = time(NULL);
}
@ -667,11 +658,11 @@ wait_for_archive(pgBackup *backup, const char *sql)
sleep(1);
if (interrupted)
elog(ERROR_INTERRUPTED,
_("interrupted during waiting for WAL archiving"));
"interrupted during waiting for WAL archiving");
try_count++;
if (try_count > TIMEOUT_ARCHIVE)
elog(ERROR_ARCHIVE_FAILED,
_("switched WAL could not be archived in %d seconds"),
"switched WAL could not be archived in %d seconds",
TIMEOUT_ARCHIVE);
}
elog(LOG, "%s() .ready deleted in %d try", __FUNCTION__, try_count);
@ -712,7 +703,7 @@ get_lsn(PGresult *res, XLogRecPtr *lsn)
if (res == NULL || PQntuples(res) != 1 || PQnfields(res) != 1)
elog(ERROR_PG_COMMAND,
_("result of backup command is invalid: %s"),
"result of backup command is invalid: %s",
PQerrorMessage(connection));
/*
@ -731,15 +722,15 @@ get_lsn(PGresult *res, XLogRecPtr *lsn)
static void
get_xid(PGresult *res, uint32 *xid)
{
if(res == NULL || PQntuples(res) != 1 || PQnfields(res) != 1)
if (res == NULL || PQntuples(res) != 1 || PQnfields(res) != 1)
elog(ERROR_PG_COMMAND,
_("result of txid_current() is invalid: %s"),
"result of txid_current() is invalid: %s",
PQerrorMessage(connection));
if(sscanf(PQgetvalue(res, 0, 0), "%u", xid) != 1)
if (sscanf(PQgetvalue(res, 0, 0), "%u", xid) != 1)
{
elog(ERROR_PG_COMMAND,
_("result of txid_current() is invalid: %s"),
"result of txid_current() is invalid: %s",
PQerrorMessage(connection));
}
elog(LOG, "%s():%s", __FUNCTION__, PQgetvalue(res, 0, 0));
@ -795,8 +786,7 @@ backup_cleanup(bool fatal, void *userdata)
make_native_path(path);
if (fileExists(path))
{
if (verbose)
printf(_("backup_label exists, stop backup\n"));
elog(LOG, "backup_label exists, stop backup");
pg_stop_backup(NULL); /* don't care stop_lsn on error case */
}
@ -806,8 +796,7 @@ backup_cleanup(bool fatal, void *userdata)
*/
if (current.status == BACKUP_STATUS_RUNNING && current.end_time == 0)
{
if (verbose)
printf(_("backup is running, update its status to ERROR\n"));
elog(LOG, "backup is running, update its status to ERROR");
current.end_time = time(NULL);
current.status = BACKUP_STATUS_ERROR;
pgBackupWriteIni(&current);
@ -842,13 +831,13 @@ backup_files(const char *from_root,
pgFile *file = (pgFile *) parray_get(files, i);
/* If current time is rewinded, abort this backup. */
if(tv.tv_sec < file->mtime){
elog(ERROR_SYSTEM, _("current time may be rewound. Please retry with full backup mode."));
}
if (tv.tv_sec < file->mtime)
elog(ERROR_SYSTEM,
"current time may be rewound. Please retry with full backup mode.");
/* check for interrupt */
if (interrupted)
elog(ERROR_INTERRUPTED, _("interrupted during backup"));
elog(ERROR_INTERRUPTED, "interrupted during backup");
/* print progress in verbose mode */
if (verbose)
@ -857,10 +846,11 @@ backup_files(const char *from_root,
{
char path[MAXPGPATH];
join_path_components(path, prefix, file->path + strlen(from_root) + 1);
printf(_("(%d/%lu) %s "), i + 1, (unsigned long) parray_num(files), path);
elog(LOG, "(%d/%lu) %s", i + 1,
(unsigned long) parray_num(files), path);
}
else
printf(_("(%d/%lu) %s "), i + 1, (unsigned long) parray_num(files),
elog(LOG, "(%d/%lu) %s", i + 1, (unsigned long) parray_num(files),
file->path + strlen(from_root) + 1);
}
@ -872,16 +862,14 @@ backup_files(const char *from_root,
{
/* record as skipped file in file_xxx.txt */
file->write_size = BYTES_INVALID;
if (verbose)
printf(_("skip\n"));
elog(LOG, "skip");
continue;
}
else
{
if (verbose)
printf("\n");
elog(LOG, "\n");
elog(ERROR_SYSTEM,
_("can't stat backup mode. \"%s\": %s"),
"can't stat backup mode. \"%s\": %s",
file->path, strerror(errno));
}
}
@ -892,11 +880,9 @@ backup_files(const char *from_root,
char dirpath[MAXPGPATH];
join_path_components(dirpath, to_root, JoinPathEnd(file->path, from_root));
if (!check){
if (!check)
dir_create_dir(dirpath, DIR_PERMISSION);
}
if (verbose)
printf(_("directory\n"));
elog(LOG, "directory");
}
else if (S_ISREG(buf.st_mode))
{
@ -939,8 +925,7 @@ backup_files(const char *from_root,
{
/* record as skipped file in file_xxx.txt */
file->write_size = BYTES_INVALID;
if (verbose)
printf(_("skip\n"));
elog(LOG, "skip");
continue;
}
}
@ -969,19 +954,14 @@ backup_files(const char *from_root,
{
/* record as skipped file in file_xxx.txt */
file->write_size = BYTES_INVALID;
if (verbose)
printf(_("skip\n"));
elog(LOG, "skip");
continue;
}
if (verbose)
printf(_("copied %lu\n"), (unsigned long) file->write_size);
elog(LOG, "copied %lu", (unsigned long) file->write_size);
}
else
{
if (verbose)
printf(_(" unexpected file type %d\n"), buf.st_mode);
}
elog(LOG, "unexpected file type %d", buf.st_mode);
}
}
@ -1061,7 +1041,7 @@ create_file_list(parray *files,
pgBackupGetPath(&current, path, lengthof(path), subdir);
fp = fopen(path, is_append ? "at" : "wt");
if (fp == NULL)
elog(ERROR_SYSTEM, _("can't open file list \"%s\": %s"), path,
elog(ERROR_SYSTEM, "can't open file list \"%s\": %s", path,
strerror(errno));
dir_print_file_list(fp, files, root, prefix);
fclose(fp);
@ -1084,7 +1064,7 @@ get_current_timeline(void)
/* .. Then interpret it */
if (size != PG_CONTROL_SIZE)
elog(ERROR_CORRUPTED, "unexpected control file size %d, expected %d\n",
elog(ERROR_CORRUPTED, "unexpected control file size %d, expected %d",
(int) size, PG_CONTROL_SIZE);
memcpy(&control_file, buffer, sizeof(ControlFileData));

View File

@ -41,7 +41,7 @@ catalog_lock(void)
lock_fd = open(id_path, O_RDWR);
if (lock_fd == -1)
elog(errno == ENOENT ? ERROR_CORRUPTED : ERROR_SYSTEM,
_("can't open file \"%s\": %s"), id_path, strerror(errno));
"cannot open file \"%s\": %s", id_path, strerror(errno));
ret = flock(lock_fd, LOCK_EX | LOCK_NB); /* non-blocking */
if (ret == -1)
@ -55,7 +55,7 @@ catalog_lock(void)
{
int errno_tmp = errno;
close(lock_fd);
elog(ERROR_SYSTEM, _("can't lock file \"%s\": %s"), id_path,
elog(ERROR_SYSTEM, "cannot lock file \"%s\": %s", id_path,
strerror(errno_tmp));
}
}
@ -147,7 +147,7 @@ catalog_get_backup_list(const pgBackupRange *range)
date_dir = opendir(backup_path);
if (date_dir == NULL)
{
elog(WARNING, _("can't open directory \"%s\": %s"), backup_path,
elog(WARNING, "cannot open directory \"%s\": %s", backup_path,
strerror(errno));
goto err_proc;
}
@ -175,7 +175,7 @@ catalog_get_backup_list(const pgBackupRange *range)
time_dir = opendir(date_path);
if (time_dir == NULL)
{
elog(WARNING, _("can't open directory \"%s\": %s"),
elog(WARNING, "cannot open directory \"%s\": %s",
date_ent->d_name, strerror(errno));
goto err_proc;
}
@ -206,7 +206,7 @@ catalog_get_backup_list(const pgBackupRange *range)
}
if (errno && errno != ENOENT)
{
elog(WARNING, _("can't read date directory \"%s\": %s"),
elog(WARNING, "cannot read date directory \"%s\": %s",
date_ent->d_name, strerror(errno));
goto err_proc;
}
@ -215,7 +215,7 @@ catalog_get_backup_list(const pgBackupRange *range)
}
if (errno)
{
elog(WARNING, _("can't read backup root directory \"%s\": %s"),
elog(WARNING, "cannot read backup root directory \"%s\": %s",
backup_path, strerror(errno));
goto err_proc;
}
@ -298,7 +298,6 @@ pgBackupWriteConfigSection(FILE *out, pgBackup *backup)
static const char *modes[] = { "", "PAGE", "FULL"};
fprintf(out, "# configuration\n");
fprintf(out, "BACKUP_MODE=%s\n", modes[backup->backup_mode]);
}
@ -352,7 +351,7 @@ pgBackupWriteIni(pgBackup *backup)
pgBackupGetPath(backup, ini_path, lengthof(ini_path), BACKUP_INI_FILE);
fp = fopen(ini_path, "wt");
if (fp == NULL)
elog(ERROR_SYSTEM, _("can't open INI file \"%s\": %s"), ini_path,
elog(ERROR_SYSTEM, "cannot open INI file \"%s\": %s", ini_path,
strerror(errno));
/* configuration section */
@ -396,9 +395,8 @@ catalog_read_ini(const char *path)
{ 0 }
};
if (access(path, F_OK) != 0){
if (access(path, F_OK) != 0)
return NULL;
}
backup = pgut_new(pgBackup);
catalog_init_config(backup);
@ -434,7 +432,7 @@ catalog_read_ini(const char *path)
if (sscanf(start_lsn, "%X/%X", &xlogid, &xrecoff) == 2)
backup->start_lsn = (XLogRecPtr) ((uint64) xlogid << 32) | xrecoff;
else
elog(WARNING, _("invalid START_LSN \"%s\""), start_lsn);
elog(WARNING, "invalid START_LSN \"%s\"", start_lsn);
free(start_lsn);
}
@ -446,7 +444,7 @@ catalog_read_ini(const char *path)
if (sscanf(stop_lsn, "%X/%X", &xlogid, &xrecoff) == 2)
backup->stop_lsn = (XLogRecPtr) ((uint64) xlogid << 32) | xrecoff;
else
elog(WARNING, _("invalid STOP_LSN \"%s\""), stop_lsn);
elog(WARNING, "invalid STOP_LSN \"%s\"", stop_lsn);
free(stop_lsn);
}
@ -467,7 +465,7 @@ catalog_read_ini(const char *path)
else if (strcmp(status, "CORRUPT") == 0)
backup->status = BACKUP_STATUS_CORRUPT;
else
elog(WARNING, _("invalid STATUS \"%s\""), status);
elog(WARNING, "invalid STATUS \"%s\"", status);
free(status);
}
@ -491,7 +489,7 @@ parse_backup_mode(const char *value)
return BACKUP_MODE_DIFF_PAGE;
/* Backup mode is invalid, so leave with an error */
elog(ERROR_ARGS, _("invalid backup-mode \"%s\""), value);
elog(ERROR_ARGS, "invalid backup-mode \"%s\"", value);
return BACKUP_MODE_INVALID;
}

48
data.c
View File

@ -96,7 +96,7 @@ backup_data_file(const char *from_root, const char *to_root,
if (errno == ENOENT)
return false;
elog(ERROR_SYSTEM, _("can't open backup mode file \"%s\": %s"),
elog(ERROR_SYSTEM, "cannot open backup mode file \"%s\": %s",
file->path, strerror(errno));
}
@ -110,7 +110,7 @@ backup_data_file(const char *from_root, const char *to_root,
{
int errno_tmp = errno;
fclose(in);
elog(ERROR_SYSTEM, _("can't open backup file \"%s\": %s"),
elog(ERROR_SYSTEM, "cannot open backup file \"%s\": %s",
to_path, strerror(errno_tmp));
}
@ -160,7 +160,7 @@ backup_data_file(const char *from_root, const char *to_root,
/* oops */
fclose(in);
fclose(out);
elog(ERROR_SYSTEM, _("can't write at block %u of \"%s\": %s"),
elog(ERROR_SYSTEM, "cannot write at block %u of \"%s\": %s",
blknum, to_path, strerror(errno_tmp));
}
@ -176,7 +176,7 @@ backup_data_file(const char *from_root, const char *to_root,
{
fclose(in);
fclose(out);
elog(ERROR_SYSTEM, _("can't read backup mode file \"%s\": %s"),
elog(ERROR_SYSTEM, "cannot read backup mode file \"%s\": %s",
file->path, strerror(errno_tmp));
}
@ -206,7 +206,7 @@ backup_data_file(const char *from_root, const char *to_root,
fclose(in);
fclose(out);
elog(ERROR_SYSTEM,
_("can't write at block %u of \"%s\": %s"),
"cannot write at block %u of \"%s\": %s",
blknum, to_path, strerror(errno_tmp));
}
COMP_CRC32C(crc, &header, sizeof(header));
@ -220,7 +220,7 @@ backup_data_file(const char *from_root, const char *to_root,
/* oops */
fclose(in);
fclose(out);
elog(ERROR_SYSTEM, _("can't write at block %u of \"%s\": %s"),
elog(ERROR_SYSTEM, "cannot write at block %u of \"%s\": %s",
blknum, to_path, strerror(errno_tmp));
}
@ -239,7 +239,7 @@ backup_data_file(const char *from_root, const char *to_root,
int errno_tmp = errno;
fclose(in);
fclose(out);
elog(ERROR_SYSTEM, _("can't change mode of \"%s\": %s"), file->path,
elog(ERROR_SYSTEM, "cannot change mode of \"%s\": %s", file->path,
strerror(errno_tmp));
}
@ -258,7 +258,7 @@ backup_data_file(const char *from_root, const char *to_root,
if (file->write_size == 0 && file->read_size > 0)
{
if (remove(to_path) == -1)
elog(ERROR_SYSTEM, _("can't remove file \"%s\": %s"), to_path,
elog(ERROR_SYSTEM, "cannot remove file \"%s\": %s", to_path,
strerror(errno));
return false;
}
@ -296,7 +296,7 @@ restore_data_file(const char *from_root,
in = fopen(file->path, "r");
if (in == NULL)
{
elog(ERROR_SYSTEM, _("can't open backup file \"%s\": %s"), file->path,
elog(ERROR_SYSTEM, "cannot open backup file \"%s\": %s", file->path,
strerror(errno));
}
@ -313,7 +313,7 @@ restore_data_file(const char *from_root,
{
int errno_tmp = errno;
fclose(in);
elog(ERROR_SYSTEM, _("can't open restore target file \"%s\": %s"),
elog(ERROR_SYSTEM, "cannot open restore target file \"%s\": %s",
to_path, strerror(errno_tmp));
}
@ -334,12 +334,12 @@ restore_data_file(const char *from_root,
else if (read_len != 0 && feof(in))
{
elog(ERROR_CORRUPTED,
_("odd size page found at block %u of \"%s\""),
"odd size page found at block %u of \"%s\"",
blknum, file->path);
}
else
{
elog(ERROR_SYSTEM, _("can't read block %u of \"%s\": %s"),
elog(ERROR_SYSTEM, "cannot read block %u of \"%s\": %s",
blknum, file->path, strerror(errno_tmp));
}
}
@ -347,7 +347,7 @@ restore_data_file(const char *from_root,
if (header.block < blknum || header.hole_offset > BLCKSZ ||
(int) header.hole_offset + (int) header.hole_length > BLCKSZ)
{
elog(ERROR_CORRUPTED, _("backup is broken at block %u"),
elog(ERROR_CORRUPTED, "backup is broken at block %u",
blknum);
}
@ -360,7 +360,7 @@ restore_data_file(const char *from_root,
if (fread(page.data, 1, header.hole_offset, in) != header.hole_offset ||
fread(page.data + upper_offset, 1, upper_length, in) != upper_length)
{
elog(ERROR_SYSTEM, _("can't read block %u of \"%s\": %s"),
elog(ERROR_SYSTEM, "cannot read block %u of \"%s\": %s",
blknum, file->path, strerror(errno));
}
@ -370,10 +370,10 @@ restore_data_file(const char *from_root,
*/
blknum = header.block;
if (fseek(out, blknum * BLCKSZ, SEEK_SET) < 0)
elog(ERROR_SYSTEM, _("can't seek block %u of \"%s\": %s"),
elog(ERROR_SYSTEM, "cannot seek block %u of \"%s\": %s",
blknum, to_path, strerror(errno));
if (fwrite(page.data, 1, sizeof(page), out) != sizeof(page))
elog(ERROR_SYSTEM, _("can't write block %u of \"%s\": %s"),
elog(ERROR_SYSTEM, "cannot write block %u of \"%s\": %s",
blknum, file->path, strerror(errno));
}
@ -383,7 +383,7 @@ restore_data_file(const char *from_root,
int errno_tmp = errno;
fclose(in);
fclose(out);
elog(ERROR_SYSTEM, _("can't change mode of \"%s\": %s"), to_path,
elog(ERROR_SYSTEM, "cannot change mode of \"%s\": %s", to_path,
strerror(errno_tmp));
}
@ -420,7 +420,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
if (errno == ENOENT)
return false;
elog(ERROR_SYSTEM, _("can't open source file \"%s\": %s"), file->path,
elog(ERROR_SYSTEM, "cannot open source file \"%s\": %s", file->path,
strerror(errno));
}
@ -434,7 +434,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
{
int errno_tmp = errno;
fclose(in);
elog(ERROR_SYSTEM, _("can't open destination file \"%s\": %s"),
elog(ERROR_SYSTEM, "cannot open destination file \"%s\": %s",
to_path, strerror(errno_tmp));
}
@ -443,7 +443,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
{
fclose(in);
fclose(out);
elog(ERROR_SYSTEM, _("can't stat \"%s\": %s"), file->path,
elog(ERROR_SYSTEM, "cannot stat \"%s\": %s", file->path,
strerror(errno));
}
@ -459,7 +459,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
/* oops */
fclose(in);
fclose(out);
elog(ERROR_SYSTEM, _("can't write to \"%s\": %s"), to_path,
elog(ERROR_SYSTEM, "cannot write to \"%s\": %s", to_path,
strerror(errno_tmp));
}
/* update CRC */
@ -474,7 +474,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
{
fclose(in);
fclose(out);
elog(ERROR_SYSTEM, _("can't read backup mode file \"%s\": %s"),
elog(ERROR_SYSTEM, "cannot read backup mode file \"%s\": %s",
file->path, strerror(errno_tmp));
}
@ -487,7 +487,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
/* oops */
fclose(in);
fclose(out);
elog(ERROR_SYSTEM, _("can't write to \"%s\": %s"), to_path,
elog(ERROR_SYSTEM, "cannot write to \"%s\": %s", to_path,
strerror(errno_tmp));
}
/* update CRC */
@ -507,7 +507,7 @@ copy_file(const char *from_root, const char *to_root, pgFile *file)
errno_tmp = errno;
fclose(in);
fclose(out);
elog(ERROR_SYSTEM, _("can't change mode of \"%s\": %s"), to_path,
elog(ERROR_SYSTEM, "cannot change mode of \"%s\": %s", to_path,
strerror(errno_tmp));
}

View File

@ -21,20 +21,20 @@ do_delete(pgBackupRange *range)
/* DATE are always required */
if (!pgBackupRangeIsValid(range))
elog(ERROR_ARGS, _("required delete range option not specified: delete DATE"));
elog(ERROR_ARGS, "required delete range option not specified: delete DATE");
/* Lock backup catalog */
ret = catalog_lock();
if (ret == -1)
elog(ERROR_SYSTEM, _("can't lock backup catalog."));
elog(ERROR_SYSTEM, "can't lock backup catalog.");
else if (ret == 1)
elog(ERROR_ALREADY_RUNNING,
_("another pg_arman is running, stop delete."));
"another pg_arman is running, stop delete.");
/* Get complete list of backup */
backup_list = catalog_get_backup_list(NULL);
if (!backup_list)
elog(ERROR_SYSTEM, _("No backup list found, can't process any more."));
elog(ERROR_SYSTEM, "No backup list found, can't process any more.");
/* Find backups to be deleted */
for (i = 0; i < parray_num(backup_list); i++)
@ -46,7 +46,7 @@ do_delete(pgBackupRange *range)
{
/* check for interrupt */
if (interrupted)
elog(ERROR_INTERRUPTED, _("interrupted during delete backup"));
elog(ERROR_INTERRUPTED, "interrupted during delete backup");
pgBackupDeleteFiles(backup);
continue;
@ -97,8 +97,8 @@ pgBackupDelete(int keep_generations, int keep_days)
else
snprintf(days_str, lengthof(days_str), "%d", keep_days);
printf(_("delete old backups (generations=%s, days=%s)\n"),
generations_str, days_str);
elog(LOG, "deleted old backups (generations=%s, days=%s)\n",
generations_str, days_str);
}
/* Leave if an infinite generation of backups is kept */
@ -181,7 +181,7 @@ pgBackupDeleteFiles(pgBackup *backup)
time2iso(timestamp, lengthof(timestamp), backup->start_time);
elog(INFO, _("delete: %s"), timestamp);
elog(INFO, "delete: %s", timestamp);
/*
* update STATUS to BACKUP_STATUS_DELETING in preparation for the case which
@ -205,7 +205,7 @@ pgBackupDeleteFiles(pgBackup *backup)
pgFile *file = (pgFile *) parray_get(files, i);
/* print progress */
elog(LOG, _("delete file(%d/%lu) \"%s\"\n"), i + 1,
elog(LOG, "delete file(%d/%lu) \"%s\"", i + 1,
(unsigned long) parray_num(files), file->path);
/* skip actual deletion in check mode */
@ -213,7 +213,7 @@ pgBackupDeleteFiles(pgBackup *backup)
{
if (remove(file->path))
{
elog(WARNING, _("can't remove \"%s\": %s"), file->path,
elog(WARNING, "can't remove \"%s\": %s", file->path,
strerror(errno));
parray_walk(files, pgFileFree);
parray_free(files);

39
dir.c
View File

@ -55,7 +55,7 @@ dir_create_dir(const char *dir, mode_t mode)
{
if (errno == EEXIST) /* already exist */
return 0;
elog(ERROR_SYSTEM, _("can't create directory \"%s\": %s"), dir,
elog(ERROR_SYSTEM, "cannot create directory \"%s\": %s", dir,
strerror(errno));
}
@ -74,7 +74,7 @@ pgFileNew(const char *path, bool omit_symlink)
/* file not found is not an error case */
if (errno == ENOENT)
return NULL;
elog(ERROR_SYSTEM, _("can't stat file \"%s\": %s"), path,
elog(ERROR_SYSTEM, "cannot stat file \"%s\": %s", path,
strerror(errno));
}
@ -109,7 +109,7 @@ pgFileDelete(pgFile *file)
else if (errno == ENOTDIR) /* could be symbolic link */
goto delete_file;
elog(ERROR_SYSTEM, _("can't remove directory \"%s\": %s"),
elog(ERROR_SYSTEM, "cannot remove directory \"%s\": %s",
file->path, strerror(errno));
}
return;
@ -120,7 +120,7 @@ delete_file:
{
if (errno == ENOENT)
return;
elog(ERROR_SYSTEM, _("can't remove file \"%s\": %s"), file->path,
elog(ERROR_SYSTEM, "cannot remove file \"%s\": %s", file->path,
strerror(errno));
}
}
@ -137,7 +137,7 @@ pgFileGetCRC(pgFile *file)
/* open file in binary read mode */
fp = fopen(file->path, "r");
if (fp == NULL)
elog(ERROR_SYSTEM, _("can't open file \"%s\": %s"),
elog(ERROR_SYSTEM, "cannot open file \"%s\": %s",
file->path, strerror(errno));
/* calc CRC of backup file */
@ -145,12 +145,12 @@ pgFileGetCRC(pgFile *file)
while ((len = fread(buf, 1, sizeof(buf), fp)) == sizeof(buf))
{
if (interrupted)
elog(ERROR_INTERRUPTED, _("interrupted during CRC calculation"));
elog(ERROR_INTERRUPTED, "interrupted during CRC calculation");
COMP_CRC32C(crc, buf, len);
}
errno_tmp = errno;
if (!feof(fp))
elog(WARNING, _("can't read \"%s\": %s"), file->path,
elog(WARNING, "cannot read \"%s\": %s", file->path,
strerror(errno_tmp));
if (len > 0)
COMP_CRC32C(crc, buf, len);
@ -241,7 +241,7 @@ dir_list_file(parray *files, const char *root, const char *exclude[], bool omit_
black_list = parray_new();
black_list_file = fopen(path, "r");
if (black_list_file == NULL)
elog(ERROR_SYSTEM, _("can't open black_list: %s"),
elog(ERROR_SYSTEM, "cannot open black_list: %s",
strerror(errno));
while (fgets(buf, lengthof(buf), black_list_file) != NULL)
{
@ -289,7 +289,7 @@ dir_list_file_internal(parray *files, const char *root, const char *exclude[],
len = readlink(file->path, linked, sizeof(linked));
if (len == -1)
{
elog(ERROR_SYSTEM, _("can't read link \"%s\": %s"), file->path,
elog(ERROR_SYSTEM, "cannot read link \"%s\": %s", file->path,
strerror(errno));
}
linked[len] = '\0';
@ -371,7 +371,7 @@ dir_list_file_internal(parray *files, const char *root, const char *exclude[],
/* maybe the direcotry was removed */
return;
}
elog(ERROR_SYSTEM, _("can't open directory \"%s\": %s"),
elog(ERROR_SYSTEM, "cannot open directory \"%s\": %s",
file->path, strerror(errno));
}
@ -392,7 +392,7 @@ dir_list_file_internal(parray *files, const char *root, const char *exclude[],
{
int errno_tmp = errno;
closedir(dir);
elog(ERROR_SYSTEM, _("can't read directory \"%s\": %s"),
elog(ERROR_SYSTEM, "cannot read directory \"%s\": %s",
file->path, strerror(errno_tmp));
}
closedir(dir);
@ -510,7 +510,7 @@ dir_read_file_list(const char *root, const char *file_txt)
fp = fopen(file_txt, "rt");
if (fp == NULL)
elog(errno == ENOENT ? ERROR_CORRUPTED : ERROR_SYSTEM,
_("can't open \"%s\": %s"), file_txt, strerror(errno));
"cannot open \"%s\": %s", file_txt, strerror(errno));
files = parray_new();
@ -530,12 +530,12 @@ dir_read_file_list(const char *root, const char *file_txt)
&tm.tm_year, &tm.tm_mon, &tm.tm_mday,
&tm.tm_hour, &tm.tm_min, &tm.tm_sec) != 11)
{
elog(ERROR_CORRUPTED, _("invalid format found in \"%s\""),
elog(ERROR_CORRUPTED, "invalid format found in \"%s\"",
file_txt);
}
if (type != 'f' && type != 'F' && type != 'd' && type != 'l')
{
elog(ERROR_CORRUPTED, _("invalid type '%c' found in \"%s\""),
elog(ERROR_CORRUPTED, "invalid type '%c' found in \"%s\"",
type, file_txt);
}
tm.tm_isdst = -1;
@ -590,17 +590,16 @@ dir_copy_files(const char *from_root, const char *to_root)
char to_path[MAXPGPATH];
join_path_components(to_path, to_root, file->path + strlen(from_root) + 1);
if (verbose && !check)
printf(_("create directory \"%s\"\n"),
file->path + strlen(from_root) + 1);
if (!check) {
elog(LOG, "creating directory \"%s\"",
file->path + strlen(from_root) + 1);
if (!check)
dir_create_dir(to_path, DIR_PERMISSION);
}
continue;
}
else if(S_ISREG(file->mode))
else if (S_ISREG(file->mode))
{
if (verbose && !check)
printf(_("copy \"%s\"\n"),
elog(LOG, "copying \"%s\"",
file->path + strlen(from_root) + 1);
if (!check)
copy_file(from_root, to_root, file);

View File

@ -202,9 +202,6 @@ absolute paths; relative paths are not allowed.
parameters and required resources. The option is typically used with
--verbose option to verify the operation.
*-v* / *--verbose*::
If specified, pg_arman works in verbose mode.
=== BACKUP OPTIONS ===
*-b* _BACKUPMODE_ / *--backup-mode*=_BACKUPMODE_::
@ -292,8 +289,8 @@ Parameters to connect PostgreSQL server.
*-V* / *--version*::
Print version information, then exit.
*-!* / *--debug*::
Show debug information.
*-v* / *--verbose*::
If specified, pg_arman works in verbose mode.
== PARAMETERS ==
@ -357,6 +354,11 @@ are required if the value contains whitespaces. Comments should start with
"#" and are automatically ignored. Whitespaces and tabs are ignored
excluding values.
=== Restrictions ===
In order to work, the PostgreSQL instance on which backups are taken need
to have data checksums enabled or to enable wal_log_hints. pg_arman is
aimed at working with PostgreSQL 9.5 and newer versions.
=== EXIT CODE ===
pg_arman returns exit codes for each error status.
@ -382,7 +384,7 @@ pg_arman returns exit codes for each error status.
26 ERROR_PID_BROKEN postmaster.pid is broken
== AUTHOR ==
pg_arman is a fork of pg_arman that was originally written by NTT, now developed
and maintained by Michael Paquier.
pg_arman is a fork of pg_arman that was originally written by NTT, now
developed and maintained by Michael Paquier.
Please report bug reports at <https://github.com/michaelpq/pg_arman>.

View File

@ -23,7 +23,7 @@ results/init/backup/backup/pg_xlog/
results/init/backup/pg_arman.ini
###### INIT COMMAND TEST-0004 ######
###### failure with backup catalog already existed ######
ERROR: backup catalog already exist. and it's not empty.
ERROR: backup catalog already exist. and it's not empty
2
###### INIT COMMAND TEST-0005 ######

View File

@ -16,7 +16,6 @@ Common Options:
-A, --arclog-path=PATH location of archive WAL storage area
-B, --backup-path=PATH location of the backup storage area
-c, --check show what would have been done
-v, --verbose output process information
Backup options:
-b, --backup-mode=MODE full or page
@ -44,7 +43,7 @@ Connection options:
Generic options:
-q, --quiet don't write any messages
--debug debug mode
-v, --verbose verbose mode
--help show this help, then exit
--version output version information, then exit

View File

@ -43,11 +43,11 @@ slurpFile(const char *datadir, const char *path, size_t *filesize)
snprintf(fullpath, sizeof(fullpath), "%s/%s", datadir, path);
if ((fd = open(fullpath, O_RDONLY | PG_BINARY, 0)) == -1)
elog(ERROR_CORRUPTED, _("could not open file \"%s\" for reading: %s\n"),
elog(ERROR_CORRUPTED, "could not open file \"%s\" for reading: %s",
fullpath, strerror(errno));
if (fstat(fd, &statbuf) < 0)
elog(ERROR_CORRUPTED, _("could not open file \"%s\" for reading: %s\n"),
elog(ERROR_CORRUPTED, "could not open file \"%s\" for reading: %s",
fullpath, strerror(errno));
len = statbuf.st_size;
@ -55,7 +55,7 @@ slurpFile(const char *datadir, const char *path, size_t *filesize)
buffer = pg_malloc(len + 1);
if (read(fd, buffer, len) != len)
elog(ERROR_CORRUPTED, _("could not read file \"%s\": %s\n"),
elog(ERROR_CORRUPTED, "could not read file \"%s\": %s\n",
fullpath, strerror(errno));
close(fd);

10
init.c
View File

@ -36,11 +36,11 @@ do_init(void)
struct dirent **dp;
int results;
if (access(backup_path, F_OK) == 0){
if (access(backup_path, F_OK) == 0)
{
results = scandir(backup_path, &dp, selects, NULL);
if(results != 0){
elog(ERROR, _("backup catalog already exist. and it's not empty."));
}
if (results != 0)
elog(ERROR, "backup catalog already exist. and it's not empty");
}
/* create backup catalog root directory */
@ -64,7 +64,7 @@ do_init(void)
join_path_components(path, backup_path, PG_RMAN_INI_FILE);
fp = fopen(path, "wt");
if (fp == NULL)
elog(ERROR_SYSTEM, _("can't create pg_arman.ini: %s"), strerror(errno));
elog(ERROR_SYSTEM, "cannot create pg_arman.ini: %s", strerror(errno));
/* set ARCLOG_PATH refered with log_directory */
if (arclog_path == NULL && archive_command && archive_command[0])

View File

@ -24,7 +24,6 @@ char *pgdata;
char *arclog_path = NULL;
/* common configuration */
bool verbose = false;
bool check = false;
/* directory configuration */
@ -55,7 +54,6 @@ static pgut_option options[] =
{ 's', 'A', "arclog-path", &arclog_path, SOURCE_ENV },
{ 's', 'B', "backup-path", &backup_path, SOURCE_ENV },
/* common options */
{ 'b', 'v', "verbose", &verbose },
{ 'b', 'c', "check", &check },
/* backup options */
{ 'f', 'b', "backup-mode", opt_backup_mode, SOURCE_ENV },
@ -129,10 +127,10 @@ main(int argc, char *argv[])
/* Check if backup_path is directory. */
struct stat stat_buf;
int rc = stat(backup_path, &stat_buf);
if(rc != -1 && !S_ISDIR(stat_buf.st_mode)){
/* If rc == -1, there is no file or directory. So it's OK. */
/* If rc == -1, there is no file or directory. So it's OK. */
if (rc != -1 && !S_ISDIR(stat_buf.st_mode))
elog(ERROR_ARGS, "-B, --backup-path must be a path to directory");
}
join_path_components(path, backup_path, PG_RMAN_INI_FILE);
pgut_readopt(path, options, ERROR_ARGS);
@ -178,10 +176,9 @@ main(int argc, char *argv[])
if (backup_validate)
do_validate(&range);
}
else if (pg_strcasecmp(cmd, "restore") == 0){
else if (pg_strcasecmp(cmd, "restore") == 0)
return do_restore(target_time, target_xid,
target_inclusive, target_tli);
}
else if (pg_strcasecmp(cmd, "show") == 0)
return do_show(&range, show_all);
else if (pg_strcasecmp(cmd, "validate") == 0)
@ -214,7 +211,6 @@ pgut_help(bool details)
printf(_(" -A, --arclog-path=PATH location of archive WAL storage area\n"));
printf(_(" -B, --backup-path=PATH location of the backup storage area\n"));
printf(_(" -c, --check show what would have been done\n"));
printf(_(" -v, --verbose output process information\n"));
printf(_("\nBackup options:\n"));
printf(_(" -b, --backup-mode=MODE full or page\n"));
printf(_(" -C, --smooth-checkpoint do smooth checkpoint before backup\n"));
@ -261,11 +257,12 @@ parse_range(pgBackupRange *range, const char *arg1, const char *arg2)
&tm.tm_year, &tm.tm_mon, &tm.tm_mday,
&tm.tm_hour, &tm.tm_min, &tm.tm_sec);
if (num < 1){
if (num < 1)
{
if (strcmp(tmp,"") != 0)
elog(ERROR_ARGS, _("supplied id(%s) is invalid."), tmp);
elog(ERROR_ARGS, "supplied id(%s) is invalid", tmp);
else
elog(ERROR_ARGS, _("arguments are invalid. near \"%s\""), arg1);
elog(ERROR_ARGS, "arguments are invalid. near \"%s\"", arg1);
}
free(tmp);
@ -276,9 +273,9 @@ parse_range(pgBackupRange *range, const char *arg1, const char *arg2)
tm.tm_mon -= 1;
tm.tm_isdst = -1;
if(!IsValidTime(tm)){
elog(ERROR_ARGS, _("supplied time(%s) is invalid."), arg1);
}
if (!IsValidTime(tm))
elog(ERROR_ARGS, "supplied time(%s) is invalid.", arg1);
range->begin = mktime(&tm);
switch (num)

View File

@ -197,7 +197,6 @@ extern char *pgdata;
extern char *arclog_path;
/* common configuration */
extern bool verbose;
extern bool check;
/* current settings */

View File

@ -33,7 +33,7 @@ const char *host = NULL;
const char *port = NULL;
const char *username = NULL;
char *password = NULL;
bool debug = false;
bool verbose = false;
bool quiet = false;
#ifndef PGUT_NO_PROMPT
@ -61,12 +61,12 @@ static const char *get_username(void);
static pgut_option default_options[] =
{
{ 'b', '!', "debug" , &debug },
{ 's', 'd', "dbname" , &dbname },
{ 's', 'h', "host" , &host },
{ 's', 'p', "port" , &port },
{ 'b', 'q', "quiet" , &quiet },
{ 's', 'U', "username" , &username },
{ 'b', 'v', "verbose" , &verbose },
#ifndef PGUT_NO_PROMPT
{ 'Y', 'w', "no-password" , &prompt_password },
{ 'y', 'W', "password" , &prompt_password },
@ -986,8 +986,8 @@ pgut_execute(PGconn* conn, const char *query, int nParams, const char **params,
if (interrupted && !in_cleanup)
elog(ERROR_INTERRUPTED, "interrupted");
/* write query to elog if debug */
if (debug)
/* write query to elog if verbose */
if (verbose)
{
int i;
@ -1041,8 +1041,8 @@ pgut_send(PGconn* conn, const char *query, int nParams, const char **params, int
if (interrupted && !in_cleanup)
elog(ERROR_INTERRUPTED, "interrupted");
/* write query to elog if debug */
if (debug)
/* write query to elog if verbose */
if (verbose)
{
int i;
@ -1161,7 +1161,7 @@ elog(int elevel, const char *fmt, ...)
{
va_list args;
if (!debug && elevel <= LOG)
if (!verbose && elevel <= LOG)
return;
if (quiet && elevel < WARNING)
return;
@ -1391,7 +1391,7 @@ help(bool details)
if (details)
{
printf(" -q, --quiet don't write any messages\n");
printf(" --debug debug mode\n");
printf(" -v, --verbose verbose mode\n");
}
printf(" --help show this help, then exit\n");
printf(" --version output version information, then exit\n");

View File

@ -91,7 +91,7 @@ extern const char *host;
extern const char *port;
extern const char *username;
extern char *password;
extern bool debug;
extern bool verbose;
extern bool quiet;
#ifndef PGUT_NO_PROMPT

220
restore.c
View File

@ -32,7 +32,7 @@ static bool satisfy_recovery_target(const pgBackup *backup,
static TimeLineID get_current_timeline(void);
static TimeLineID get_fullbackup_timeline(parray *backups,
const pgRecoveryTarget *rt);
static void print_backup_id(const pgBackup *backup);
static void print_backup_lsn(const pgBackup *backup);
static void search_next_wal(const char *path,
XLogRecPtr *need_lsn,
parray *timelines);
@ -59,39 +59,34 @@ do_restore(const char *target_time,
/* PGDATA and ARCLOG_PATH are always required */
if (pgdata == NULL)
elog(ERROR_ARGS,
_("required parameter not specified: PGDATA (-D, --pgdata)"));
"required parameter not specified: PGDATA (-D, --pgdata)");
if (arclog_path == NULL)
elog(ERROR_ARGS,
_("required parameter not specified: ARCLOG_PATH (-A, --arclog-path)"));
"required parameter not specified: ARCLOG_PATH (-A, --arclog-path)");
if (verbose)
{
printf(_("========================================\n"));
printf(_("restore start\n"));
}
elog(LOG, "========================================");
elog(LOG, "restore start");
/* get exclusive lock of backup catalog */
ret = catalog_lock();
if (ret == -1)
elog(ERROR_SYSTEM, _("can't lock backup catalog."));
elog(ERROR_SYSTEM, "cannot lock backup catalog.");
else if (ret == 1)
elog(ERROR_ALREADY_RUNNING,
_("another pg_arman is running, stop restore."));
"another pg_arman is running, stop restore.");
/* confirm the PostgreSQL server is not running */
if (is_pg_running())
elog(ERROR_PG_RUNNING, _("PostgreSQL server is running"));
elog(ERROR_PG_RUNNING, "PostgreSQL server is running");
rt = checkIfCreateRecoveryConf(target_time, target_xid, target_inclusive);
if(rt == NULL){
elog(ERROR_ARGS, _("can't create recovery.conf. specified args are invalid."));
}
if (rt == NULL)
elog(ERROR_ARGS, "cannot create recovery.conf. specified args are invalid.");
/* get list of backups. (index == 0) is the last backup */
backups = catalog_get_backup_list(NULL);
if(!backups){
elog(ERROR_SYSTEM, _("can't process any more."));
}
if (!backups)
elog(ERROR_SYSTEM, "cannot process any more.");
cur_tli = get_current_timeline();
backup_tli = get_fullbackup_timeline(backups, rt);
@ -100,12 +95,9 @@ do_restore(const char *target_time,
if (target_tli == 0)
target_tli = cur_tli != 0 ? cur_tli : backup_tli;
if (verbose)
{
printf(_("current timeline ID = %u\n"), cur_tli);
printf(_("latest full backup timeline ID = %u\n"), backup_tli);
printf(_("target timeline ID = %u\n"), target_tli);
}
elog(LOG, "current timeline ID = %u", cur_tli);
elog(LOG, "latest full backup timeline ID = %u", backup_tli);
elog(LOG, "target timeline ID = %u", target_tli);
/* backup online WAL */
backup_online_files(cur_tli != 0 && cur_tli != backup_tli);
@ -116,11 +108,9 @@ do_restore(const char *target_time,
*/
if (!check)
{
if (verbose)
{
printf(_("----------------------------------------\n"));
printf(_("clearing restore destination\n"));
}
elog(LOG, "----------------------------------------");
elog(LOG, "clearing restore destination");
files = parray_new();
dir_list_file(files, pgdata, NULL, false, false);
parray_qsort(files, pgFileComparePathDesc); /* delete from leaf */
@ -138,8 +128,7 @@ do_restore(const char *target_time,
timelines = readTimeLineHistory(target_tli);
/* find last full backup which can be used as base backup. */
if (verbose)
printf(_("searching recent full backup\n"));
elog(LOG, "searching recent full backup");
for (i = 0; i < parray_num(backups); i++)
{
base_backup = (pgBackup *) parray_get(backups, i);
@ -152,14 +141,13 @@ do_restore(const char *target_time,
satisfy_recovery_target(base_backup, rt))
goto base_backup_found;
}
/* no full backup found, can't restore */
elog(ERROR_NO_BACKUP, _("no full backup found, can't restore."));
/* no full backup found, cannot restore */
elog(ERROR_NO_BACKUP, "no full backup found, cannot restore.");
base_backup_found:
base_index = i;
if (verbose)
print_backup_id(base_backup);
print_backup_lsn(base_backup);
/* restore base backup */
restore_database(base_backup);
@ -167,8 +155,7 @@ base_backup_found:
last_restored_index = base_index;
/* restore following differential backup */
if (verbose)
printf(_("searching differential backup...\n"));
elog(LOG, "searching differential backup...");
for (i = base_index - 1; i >= 0; i--)
{
pgBackup *backup = (pgBackup *) parray_get(backups, i);
@ -187,8 +174,7 @@ base_backup_found:
!satisfy_recovery_target(backup, rt))
continue;
if (verbose)
print_backup_id(backup);
print_backup_lsn(backup);
restore_database(backup);
last_restored_index = i;
@ -197,19 +183,16 @@ base_backup_found:
for (i = last_restored_index; i >= 0; i--)
{
char xlogpath[MAXPGPATH];
if (verbose)
printf(_("searching archived WAL...\n"));
elog(LOG, "searching archived WAL...");
search_next_wal(arclog_path, &need_lsn, timelines);
if (verbose)
printf(_("searching online WAL...\n"));
elog(LOG, "searching online WAL...");
join_path_components(xlogpath, pgdata, PG_XLOG_DIR);
search_next_wal(xlogpath, &need_lsn, timelines);
if (verbose)
printf(_("all necessary files are found.\n"));
elog(LOG, "all necessary files are found");
}
/* create recovery.conf */
@ -223,13 +206,13 @@ base_backup_found:
parray_free(backups);
/* print restore complete message */
if (verbose && !check)
if (!check)
{
printf(_("all restore completed\n"));
printf(_("========================================\n"));
elog(LOG, "all restore completed");
elog(LOG, "========================================");
}
if (!check)
elog(INFO, _("restore complete. Recovery starts automatically when the PostgreSQL server is started."));
elog(INFO, "restore complete. Recovery starts automatically when the PostgreSQL server is started.");
return 0;
}
@ -250,18 +233,18 @@ restore_database(pgBackup *backup)
/* confirm block size compatibility */
if (backup->block_size != BLCKSZ)
elog(ERROR_PG_INCOMPATIBLE,
_("BLCKSZ(%d) is not compatible(%d expected)"),
"BLCKSZ(%d) is not compatible(%d expected)",
backup->block_size, BLCKSZ);
if (backup->wal_block_size != XLOG_BLCKSZ)
elog(ERROR_PG_INCOMPATIBLE,
_("XLOG_BLCKSZ(%d) is not compatible(%d expected)"),
"XLOG_BLCKSZ(%d) is not compatible(%d expected)",
backup->wal_block_size, XLOG_BLCKSZ);
time2iso(timestamp, lengthof(timestamp), backup->start_time);
if (verbose && !check)
if (!check)
{
printf(_("----------------------------------------\n"));
printf(_("restoring database from backup %s.\n"), timestamp);
elog(LOG, "----------------------------------------");
elog(LOG, "restoring database from backup %s", timestamp);
}
/*
@ -278,7 +261,7 @@ restore_database(pgBackup *backup)
/* keep orginal directory */
if (getcwd(pwd, sizeof(pwd)) == NULL)
elog(ERROR_SYSTEM, _("can't get current working directory: %s"),
elog(ERROR_SYSTEM, "cannot get current working directory: %s",
strerror(errno));
/* create pgdata directory */
@ -286,18 +269,18 @@ restore_database(pgBackup *backup)
/* change directory to pgdata */
if (chdir(pgdata))
elog(ERROR_SYSTEM, _("can't change directory: %s"),
elog(ERROR_SYSTEM, "cannot change directory: %s",
strerror(errno));
/* Execute mkdirs.sh */
ret = system(path);
if (ret != 0)
elog(ERROR_SYSTEM, _("can't execute mkdirs.sh: %s"),
elog(ERROR_SYSTEM, "cannot execute mkdirs.sh: %s",
strerror(errno));
/* go back to original directory */
if (chdir(pwd))
elog(ERROR_SYSTEM, _("can't change directory: %s"),
elog(ERROR_SYSTEM, "cannot change directory: %s",
strerror(errno));
}
@ -326,26 +309,26 @@ restore_database(pgBackup *backup)
/* check for interrupt */
if (interrupted)
elog(ERROR_INTERRUPTED, _("interrupted during restore database"));
elog(ERROR_INTERRUPTED, "interrupted during restore database");
/* print progress */
if (verbose && !check)
printf(_("(%d/%lu) %s "), i + 1, (unsigned long) parray_num(files),
if (!check)
elog(LOG, "(%d/%lu) %s ", i + 1, (unsigned long) parray_num(files),
file->path + strlen(from_root) + 1);
/* directories are created with mkdirs.sh */
if (S_ISDIR(file->mode))
{
if (verbose && !check)
printf(_("directory, skip\n"));
if (!check)
elog(LOG, "directory, skip");
continue;
}
/* not backed up */
if (file->write_size == BYTES_INVALID)
{
if (verbose && !check)
printf(_("not backed up, skip\n"));
if (!check)
elog(LOG, "not backed up, skip");
continue;
}
@ -354,8 +337,8 @@ restore_database(pgBackup *backup)
restore_data_file(from_root, pgdata, file);
/* print size of restored file */
if (verbose && !check)
printf(_("restored %lu\n"), (unsigned long) file->write_size);
if (!check)
elog(LOG, "restored %lu\n", (unsigned long) file->write_size);
}
/* Delete files which are not in file list. */
@ -383,8 +366,7 @@ restore_database(pgBackup *backup)
/* If the file is not in the file list, delete it */
if (parray_bsearch(files, file, pgFileComparePathDesc) == NULL)
{
if (verbose)
printf(_(" delete %s\n"), file->path + strlen(pgdata) + 1);
elog(LOG, "deleted %s", file->path + strlen(pgdata) + 1);
pgFileDelete(file);
}
}
@ -396,15 +378,15 @@ restore_database(pgBackup *backup)
/* remove postmaster.pid */
snprintf(path, lengthof(path), "%s/postmaster.pid", pgdata);
if (remove(path) == -1 && errno != ENOENT)
elog(ERROR_SYSTEM, _("can't remove postmaster.pid: %s"),
elog(ERROR_SYSTEM, "cannot remove postmaster.pid: %s",
strerror(errno));
/* cleanup */
parray_walk(files, pgFileFree);
parray_free(files);
if (verbose && !check)
printf(_("restore backup completed\n"));
if (!check)
elog(LOG, "restore backup completed");
}
@ -417,10 +399,10 @@ create_recovery_conf(const char *target_time,
char path[MAXPGPATH];
FILE *fp;
if (verbose && !check)
if (!check)
{
printf(_("----------------------------------------\n"));
printf(_("creating recovery.conf\n"));
elog(LOG, "----------------------------------------");
elog(LOG, "creating recovery.conf");
}
if (!check)
@ -428,7 +410,7 @@ create_recovery_conf(const char *target_time,
snprintf(path, lengthof(path), "%s/recovery.conf", pgdata);
fp = fopen(path, "wt");
if (fp == NULL)
elog(ERROR_SYSTEM, _("can't open recovery.conf \"%s\": %s"), path,
elog(ERROR_SYSTEM, "cannot open recovery.conf \"%s\": %s", path,
strerror(errno));
fprintf(fp, "# recovery.conf generated by pg_arman %s\n",
@ -454,10 +436,10 @@ backup_online_files(bool re_recovery)
bool files_exist;
parray *files;
if (verbose && !check)
if (!check)
{
printf(_("----------------------------------------\n"));
printf(_("backup online WAL start\n"));
elog(LOG, "----------------------------------------");
elog(LOG, "backup online WAL start");
}
/* get list of files in $BACKUP_PATH/backup/pg_xlog */
@ -474,9 +456,7 @@ backup_online_files(bool re_recovery)
/* If files exist in RESTORE_WORK_DIR and not re-recovery, use them. */
if (files_exist && !re_recovery)
{
if (verbose)
printf(_("online WALs have been already backed up, use them.\n"));
elog(LOG, "online WALs have been already backed up, use them");
return;
}
@ -493,7 +473,7 @@ backup_online_files(bool re_recovery)
* Try to read a timeline's history file.
*
* If successful, return the list of component pgTimeLine (the ancestor
* timelines followed by target timeline). If we can't find the history file,
* timelines followed by target timeline). If we cannot find the history file,
* assume that the timeline has no parents, and return a list of just the
* specified timeline ID.
* based on readTimeLineHistory() in xlog.c
@ -517,7 +497,7 @@ readTimeLineHistory(TimeLineID targetTLI)
if (fd == NULL)
{
if (errno != ENOENT)
elog(ERROR_SYSTEM, _("could not open file \"%s\": %s"), path,
elog(ERROR_SYSTEM, "could not open file \"%s\": %s", path,
strerror(errno));
/* search from restore work directory next */
@ -527,7 +507,7 @@ readTimeLineHistory(TimeLineID targetTLI)
if (fd == NULL)
{
if (errno != ENOENT)
elog(ERROR_SYSTEM, _("could not open file \"%s\": %s"), path,
elog(ERROR_SYSTEM, "could not open file \"%s\": %s", path,
strerror(errno));
}
}
@ -565,17 +545,17 @@ readTimeLineHistory(TimeLineID targetTLI)
{
/* expect a numeric timeline ID as first field of line */
elog(ERROR_CORRUPTED,
_("syntax error in history file: %s. Expected a numeric timeline ID."),
"syntax error in history file: %s. Expected a numeric timeline ID.",
fline);
}
if (nfields != 3)
elog(ERROR_CORRUPTED,
_("syntax error in history file: %s. Expected a transaction log switchpoint location."),
"syntax error in history file: %s. Expected a transaction log switchpoint location.",
fline);
if (last_timeline && timeline->tli <= last_timeline->tli)
elog(ERROR_CORRUPTED,
_("Timeline IDs must be in increasing sequence."));
"Timeline IDs must be in increasing sequence.");
/* Build list with newest item first */
parray_insert(result, 0, timeline);
@ -591,7 +571,7 @@ readTimeLineHistory(TimeLineID targetTLI)
if (last_timeline && targetTLI <= last_timeline->tli)
elog(ERROR_CORRUPTED,
_("Timeline IDs must be less than child timeline's ID."));
"Timeline IDs must be less than child timeline's ID.");
/* append target timeline */
timeline = pgut_new(pgTimeLine);
@ -600,10 +580,11 @@ readTimeLineHistory(TimeLineID targetTLI)
timeline->end = (uint32) (-1UL << 32) | -1UL;
parray_insert(result, 0, timeline);
/* dump timeline branches for debug */
if (debug)
/* dump timeline branches in verbose mode */
if (verbose)
{
int i;
for (i = 0; i < parray_num(result); i++)
{
pgTimeLine *timeline = parray_get(result, i);
@ -657,14 +638,14 @@ get_current_timeline(void)
if ((fd = open(ControlFilePath, O_RDONLY | PG_BINARY, 0)) == -1)
{
elog(WARNING, _("can't open pg_controldata file \"%s\": %s"),
elog(WARNING, "cannot open pg_controldata file \"%s\": %s",
ControlFilePath, strerror(errno));
return 0;
}
if (read(fd, &ControlFile, sizeof(ControlFileData)) != sizeof(ControlFileData))
{
elog(WARNING, _("can't read pg_controldata file \"%s\": %s"),
elog(WARNING, "cannot read pg_controldata file \"%s\": %s",
ControlFilePath, strerror(errno));
return 0;
}
@ -679,18 +660,18 @@ get_current_timeline(void)
if (!EQ_CRC32C(crc, ControlFile.crc))
{
elog(WARNING, _("Calculated CRC checksum does not match value stored in file.\n"
elog(WARNING, "Calculated CRC checksum does not match value stored in file.\n"
"Either the file is corrupt, or it has a different layout than this program\n"
"is expecting. The results below are untrustworthy.\n"));
"is expecting. The results below are untrustworthy.\n");
return 0;
}
if (ControlFile.pg_control_version % 65536 == 0 && ControlFile.pg_control_version / 65536 != 0)
{
elog(WARNING, _("possible byte ordering mismatch\n"
elog(WARNING, "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"
"the PostgreSQL installation would be incompatible with this data directory.\n"));
"the PostgreSQL installation would be incompatible with this data directory.\n");
return 0;
}
@ -720,16 +701,16 @@ get_fullbackup_timeline(parray *backups, const pgRecoveryTarget *rt)
if (base_backup->status == BACKUP_STATUS_DONE)
pgBackupValidate(base_backup, true, true);
if(!satisfy_recovery_target(base_backup, rt))
if (!satisfy_recovery_target(base_backup, rt))
continue;
if (base_backup->status == BACKUP_STATUS_OK)
break;
}
}
/* no full backup found, can't restore */
/* no full backup found, cannot restore */
if (i == parray_num(backups))
elog(ERROR_NO_BACKUP, _("no full backup found, can't restore."));
elog(ERROR_NO_BACKUP, "no full backup found, cannot restore.");
ret = base_backup->tli;
@ -737,14 +718,18 @@ get_fullbackup_timeline(parray *backups, const pgRecoveryTarget *rt)
}
static void
print_backup_id(const pgBackup *backup)
print_backup_lsn(const pgBackup *backup)
{
char timestamp[100];
if (!verbose)
return;
time2iso(timestamp, lengthof(timestamp), backup->start_time);
printf(_(" %s (%X/%08X)\n"),
timestamp,
(uint32) (backup->stop_lsn >> 32),
(uint32) backup->stop_lsn);
elog(LOG, " %s (%X/%08X)",
timestamp,
(uint32) (backup->stop_lsn >> 32),
(uint32) backup->stop_lsn);
}
static void
@ -778,16 +763,16 @@ search_next_wal(const char *path, XLogRecPtr *need_lsn, parray *timelines)
if (i == parray_num(timelines))
{
if (count == 1)
printf(_("\n"));
elog(LOG, "\n");
else if (count > 1)
printf(_(" - %s\n"), pre_xlogfname);
elog(LOG, " - %s", pre_xlogfname);
return;
}
count++;
if (count == 1)
printf(_("%s"), xlogfname);
elog(LOG, "%s", xlogfname);
strcpy(pre_xlogfname, xlogfname);
@ -824,25 +809,28 @@ checkIfCreateRecoveryConf(const char *target_time,
rt->recovery_target_xid = 0;
rt->recovery_target_inclusive = false;
if(target_time){
if (target_time)
{
rt->time_specified = true;
if(parse_time(target_time, &dummy_time))
if (parse_time(target_time, &dummy_time))
rt->recovery_target_time = dummy_time;
else
elog(ERROR_ARGS, _("can't create recovery.conf with %s"), target_time);
elog(ERROR_ARGS, "cannot create recovery.conf with %s", target_time);
}
if(target_xid){
if (target_xid)
{
rt->xid_specified = true;
if(parse_uint32(target_xid, &dummy_xid))
if (parse_uint32(target_xid, &dummy_xid))
rt->recovery_target_xid = dummy_xid;
else
elog(ERROR_ARGS, _("can't create recovery.conf with %s"), target_xid);
elog(ERROR_ARGS, "cannot create recovery.conf with %s", target_xid);
}
if(target_inclusive){
if(parse_bool(target_inclusive, &dummy_bool))
if (target_inclusive)
{
if (parse_bool(target_inclusive, &dummy_bool))
rt->recovery_target_inclusive = dummy_bool;
else
elog(ERROR_ARGS, _("can't create recovery.conf with %s"), target_inclusive);
elog(ERROR_ARGS, "cannot create recovery.conf with %s", target_inclusive);
}
return rt;

13
show.c
View File

@ -27,7 +27,7 @@ do_show(pgBackupRange *range, bool show_all)
*/
if (arclog_path == NULL)
elog(ERROR_ARGS,
_("required parameter not specified: ARCLOG_PATH (-A, --arclog-path)"));
"required parameter not specified: ARCLOG_PATH (-A, --arclog-path)");
if (pgBackupRangeIsSingle(range))
{
@ -38,7 +38,7 @@ do_show(pgBackupRange *range, bool show_all)
{
char timestamp[100];
time2iso(timestamp, lengthof(timestamp), range->begin);
elog(INFO, _("backup taken at \"%s\" does not exist."),
elog(INFO, "backup taken at \"%s\" does not exist.",
timestamp);
/* This is not error case */
return 0;
@ -53,9 +53,8 @@ do_show(pgBackupRange *range, bool show_all)
parray *backup_list;
backup_list = catalog_get_backup_list(range);
if (backup_list == NULL){
elog(ERROR_SYSTEM, _("can't process any more."));
}
if (backup_list == NULL)
elog(ERROR_SYSTEM, "can't process any more.");
show_backup_list(stdout, backup_list, show_all);
@ -127,7 +126,7 @@ get_parent_tli(TimeLineID child_tli)
if (fd == NULL)
{
if (errno != ENOENT)
elog(ERROR_SYSTEM, _("could not open file \"%s\": %s"), path,
elog(ERROR_SYSTEM, "could not open file \"%s\": %s", path,
strerror(errno));
return 0;
@ -154,7 +153,7 @@ get_parent_tli(TimeLineID child_tli)
result = (TimeLineID) strtoul(ptr, &endptr, 0);
if (endptr == ptr)
elog(ERROR_CORRUPTED,
_("syntax error(timeline ID) in history file: %s"),
"syntax error(timeline ID) in history file: %s",
fline);
}

View File

@ -46,7 +46,7 @@ get_pgpid(void)
return 0;
else
{
elog(ERROR_SYSTEM, _("could not open PID file \"%s\": %s\n"),
elog(ERROR_SYSTEM, "could not open PID file \"%s\": %s",
pid_file, strerror(errno));
}
}
@ -54,10 +54,10 @@ get_pgpid(void)
{
/* Is the file empty? */
if (ftell(pidf) == 0 && feof(pidf))
elog(ERROR_SYSTEM, _("the PID file \"%s\" is empty\n"),
elog(ERROR_SYSTEM, "the PID file \"%s\" is empty",
pid_file);
else
elog(ERROR_SYSTEM, _("invalid data in PID file \"%s\"\n"),
elog(ERROR_SYSTEM, "invalid data in PID file \"%s\"\n",
pid_file);
}
fclose(pidf);

View File

@ -31,17 +31,19 @@ do_validate(pgBackupRange *range)
/* get backup list matches given range */
backup_list = catalog_get_backup_list(range);
if(!backup_list){
elog(ERROR_SYSTEM, _("can't process any more."));
}
if (!backup_list)
elog(ERROR_SYSTEM, "cannot process any more.");
parray_qsort(backup_list, pgBackupCompareId);
for (i = 0; i < parray_num(backup_list); i++)
{
pgBackup *backup = (pgBackup *)parray_get(backup_list, i);
/* clean extra backups (switch STATUS to ERROR) */
if(!another_pg_arman &&
(backup->status == BACKUP_STATUS_RUNNING || backup->status == BACKUP_STATUS_DELETING)){
if (!another_pg_arman &&
(backup->status == BACKUP_STATUS_RUNNING ||
backup->status == BACKUP_STATUS_DELETING))
{
backup->status = BACKUP_STATUS_ERROR;
pgBackupWriteIni(backup);
}
@ -141,29 +143,29 @@ pgBackupValidateFiles(parray *files, const char *root, bool size_only)
pgFile *file = (pgFile *) parray_get(files, i);
if (interrupted)
elog(ERROR_INTERRUPTED, _("interrupted during validate"));
elog(ERROR_INTERRUPTED, "interrupted during validate");
/* skipped backup while differential backup */
if (file->write_size == BYTES_INVALID || !S_ISREG(file->mode))
continue;
/* print progress */
elog(LOG, _("(%d/%lu) %s"), i + 1, (unsigned long) parray_num(files),
elog(LOG, "(%d/%lu) %s", i + 1, (unsigned long) parray_num(files),
get_relative_path(file->path, root));
/* always validate file size */
if (stat(file->path, &st) == -1)
{
if (errno == ENOENT)
elog(WARNING, _("backup file \"%s\" vanished"), file->path);
elog(WARNING, "backup file \"%s\" vanished", file->path);
else
elog(ERROR_SYSTEM, _("can't stat backup file \"%s\": %s"),
elog(ERROR_SYSTEM, "cannot stat backup file \"%s\": %s",
get_relative_path(file->path, root), strerror(errno));
return false;
}
if (file->write_size != st.st_size)
{
elog(WARNING, _("size of backup file \"%s\" must be %lu but %lu"),
elog(WARNING, "size of backup file \"%s\" must be %lu but %lu",
get_relative_path(file->path, root),
(unsigned long) file->write_size,
(unsigned long) st.st_size);
@ -178,7 +180,7 @@ pgBackupValidateFiles(parray *files, const char *root, bool size_only)
crc = pgFileGetCRC(file);
if (crc != file->crc)
{
elog(WARNING, _("CRC of backup file \"%s\" must be %X but %X"),
elog(WARNING, "CRC of backup file \"%s\" must be %X but %X",
get_relative_path(file->path, root), file->crc, crc);
return false;
}