Skip to content

Commit 2cf0c99

Browse files
committed
Added --note option for set-backup command. Fixed --note option for backup command. Added char *note field to pgSetBackupParams structure
1 parent 884fed1 commit 2cf0c99

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

src/backup.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -750,7 +750,7 @@ pgdata_basic_setup(ConnectionOptions conn_opt, PGNodeInfo *nodeInfo)
750750
*/
751751
int
752752
do_backup(time_t start_time, bool no_validate,
753-
pgSetBackupParams *set_backup_params, bool no_sync, char *note)
753+
pgSetBackupParams *set_backup_params, bool no_sync)
754754
{
755755
PGconn *backup_conn = NULL;
756756
PGNodeInfo nodeInfo;
@@ -767,7 +767,7 @@ do_backup(time_t start_time, bool no_validate,
767767
current.status = BACKUP_STATUS_RUNNING;
768768
current.start_time = start_time;
769769

770-
current.note = note;
770+
current.note = set_backup_params ? set_backup_params->note : NULL;
771771

772772
StrNCpy(current.program_version, PROGRAM_VERSION,
773773
sizeof(current.program_version));

src/catalog.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1412,9 +1412,11 @@ pin_backup(pgBackup *target_backup, pgSetBackupParams *set_backup_params)
14121412
/* Pin comes from expire-time */
14131413
else if (set_backup_params->expire_time > 0)
14141414
target_backup->expire_time = set_backup_params->expire_time;
1415-
else
1415+
else if (!set_backup_params->note)
14161416
return false;
14171417

1418+
if (set_backup_params->note) target_backup->note = set_backup_params->note;
1419+
14181420
/* Update backup.control */
14191421
write_backup(target_backup);
14201422

@@ -1426,9 +1428,11 @@ pin_backup(pgBackup *target_backup, pgSetBackupParams *set_backup_params)
14261428
elog(INFO, "Backup %s is pinned until '%s'", base36enc(target_backup->start_time),
14271429
expire_timestamp);
14281430
}
1429-
else
1431+
else if (set_backup_params->ttl == 0)
14301432
elog(INFO, "Backup %s is unpinned", base36enc(target_backup->start_time));
14311433

1434+
if (set_backup_params->note)
1435+
elog(INFO, "Saved note for backup %s", base36enc(target_backup->start_time));
14321436
return true;
14331437
}
14341438

src/pg_probackup.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -726,11 +726,12 @@ main(int argc, char *argv[])
726726
expire_time_string);
727727
}
728728

729-
if (expire_time > 0 || ttl >= 0)
729+
if (expire_time > 0 || ttl >= 0 || backup_note)
730730
{
731731
set_backup_params = pgut_new(pgSetBackupParams);
732732
set_backup_params->ttl = ttl;
733733
set_backup_params->expire_time = expire_time;
734+
set_backup_params->note = backup_note;
734735
}
735736
}
736737

@@ -770,7 +771,7 @@ main(int argc, char *argv[])
770771
elog(ERROR, "required parameter not specified: BACKUP_MODE "
771772
"(-b, --backup-mode)");
772773

773-
return do_backup(start_time, no_validate, set_backup_params, no_sync, backup_note);
774+
return do_backup(start_time, no_validate, set_backup_params, no_sync);
774775
}
775776
case RESTORE_CMD:
776777
return do_restore_or_validate(current.backup_id,

src/pg_probackup.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ typedef struct pgSetBackupParams
438438
time_t expire_time; /* Point in time before which backup
439439
* must be pinned.
440440
*/
441+
char *note;
441442
} pgSetBackupParams;
442443

443444
typedef struct
@@ -644,7 +645,7 @@ extern const char *pgdata_exclude_dir[];
644645

645646
/* in backup.c */
646647
extern int do_backup(time_t start_time, bool no_validate,
647-
pgSetBackupParams *set_backup_params, bool no_sync, char *note);
648+
pgSetBackupParams *set_backup_params, bool no_sync);
648649
extern void do_checkdb(bool need_amcheck, ConnectionOptions conn_opt,
649650
char *pgdata);
650651
extern BackupMode parse_backup_mode(const char *value);
@@ -947,4 +948,8 @@ extern char *pg_ptrack_get_and_clear(Oid tablespace_oid,
947948
extern XLogRecPtr get_last_ptrack_lsn(PGconn *backup_conn, PGNodeInfo *nodeInfo);
948949
extern parray * pg_ptrack_get_pagemapset(PGconn *backup_conn, const char *ptrack_schema, XLogRecPtr lsn);
949950

951+
#ifdef WIN32
952+
#define setbuffer(stream, buf, size) setvbuf(stream, buf, buf ? _IOFBF : _IONBF, size);
953+
#endif
954+
950955
#endif /* PG_PROBACKUP_H */

0 commit comments

Comments
 (0)