1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2024-11-28 09:33:54 +02:00

PGPRO-2073: Write program-version only during backup

This commit is contained in:
Arthur Zakirov 2018-10-16 18:28:00 +03:00
parent 4e68bac2f8
commit 0b2e0469ac
3 changed files with 16 additions and 9 deletions

View File

@ -911,6 +911,8 @@ do_backup(time_t start_time)
/* Start backup. Update backup status. */ /* Start backup. Update backup status. */
current.status = BACKUP_STATUS_RUNNING; current.status = BACKUP_STATUS_RUNNING;
current.start_time = start_time; current.start_time = start_time;
StrNCpy(current.program_version, PROGRAM_VERSION,
sizeof(current.program_version));
/* Create backup directory and BACKUP_CONTROL_FILE */ /* Create backup directory and BACKUP_CONTROL_FILE */
if (pgBackupCreateDir(&current)) if (pgBackupCreateDir(&current))

View File

@ -219,7 +219,8 @@ read_backup(time_t timestamp)
/* /*
* Save the backup status into BACKUP_CONTROL_FILE. * Save the backup status into BACKUP_CONTROL_FILE.
* *
* We need to reread the backup using its ID and save it changing only its status. * We need to reread the backup using its ID and save it changing only its
* status.
*/ */
void void
write_backup_status(pgBackup *backup) write_backup_status(pgBackup *backup)
@ -227,9 +228,10 @@ write_backup_status(pgBackup *backup)
pgBackup *tmp; pgBackup *tmp;
tmp = read_backup(backup->start_time); tmp = read_backup(backup->start_time);
tmp->status = backup->status;
tmp->status = backup->status;
write_backup(tmp); write_backup(tmp);
pgBackupFree(tmp); pgBackupFree(tmp);
} }
@ -443,7 +445,8 @@ pgBackupWriteControl(FILE *out, pgBackup *backup)
fprintf(out, "block-size = %u\n", backup->block_size); fprintf(out, "block-size = %u\n", backup->block_size);
fprintf(out, "xlog-block-size = %u\n", backup->wal_block_size); fprintf(out, "xlog-block-size = %u\n", backup->wal_block_size);
fprintf(out, "checksum-version = %u\n", backup->checksum_version); fprintf(out, "checksum-version = %u\n", backup->checksum_version);
fprintf(out, "program-version = %s\n", PROGRAM_VERSION); if (backup->program_version[0] != '\0')
fprintf(out, "program-version = %s\n", backup->program_version);
if (backup->server_version[0] != '\0') if (backup->server_version[0] != '\0')
fprintf(out, "server-version = %s\n", backup->server_version); fprintf(out, "server-version = %s\n", backup->server_version);
@ -493,17 +496,19 @@ pgBackupWriteControl(FILE *out, pgBackup *backup)
fprintf(out, "primary_conninfo = '%s'\n", backup->primary_conninfo); fprintf(out, "primary_conninfo = '%s'\n", backup->primary_conninfo);
} }
/* create BACKUP_CONTROL_FILE */ /*
* Save the backup content into BACKUP_CONTROL_FILE.
*/
void void
write_backup(pgBackup *backup) write_backup(pgBackup *backup)
{ {
FILE *fp = NULL; FILE *fp = NULL;
char ini_path[MAXPGPATH]; char conf_path[MAXPGPATH];
pgBackupGetPath(backup, ini_path, lengthof(ini_path), BACKUP_CONTROL_FILE); pgBackupGetPath(backup, conf_path, lengthof(conf_path), BACKUP_CONTROL_FILE);
fp = fopen(ini_path, "wt"); fp = fopen(conf_path, "wt");
if (fp == NULL) if (fp == NULL)
elog(ERROR, "cannot open configuration file \"%s\": %s", ini_path, elog(ERROR, "Cannot open configuration file \"%s\": %s", conf_path,
strerror(errno)); strerror(errno));
pgBackupWriteControl(fp, backup); pgBackupWriteControl(fp, backup);

View File

@ -241,7 +241,7 @@ assign_option(pgut_option *opt, const char *optarg, pgut_optsrc src)
*(char **) opt->var = pgut_strdup(optarg); *(char **) opt->var = pgut_strdup(optarg);
if (strcmp(optarg,"") != 0) if (strcmp(optarg,"") != 0)
return; return;
message = "a valid string. But provided: "; message = "a valid string";
break; break;
case 't': case 't':
if (parse_time(optarg, opt->var, if (parse_time(optarg, opt->var,