mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-03-17 21:18:00 +02:00
Revert "Issue #31: Use UTC time to make backup ID"
This reverts commit 4877f6b5d48842e6f9ead7f42431225d451fcdef.
This commit is contained in:
parent
4877f6b5d4
commit
188bb11196
@ -553,7 +553,7 @@ do_backup_instance(void)
|
||||
pg_ptrack_clear();
|
||||
|
||||
/* notify start of backup to PostgreSQL server */
|
||||
time2iso(label, lengthof(label), current.start_time, true);
|
||||
time2iso(label, lengthof(label), current.start_time);
|
||||
strncat(label, " with pg_probackup", lengthof(label) -
|
||||
strlen(" with pg_probackup"));
|
||||
pg_start_backup(label, smooth_checkpoint, ¤t);
|
||||
|
@ -409,17 +409,17 @@ pgBackupWriteControl(FILE *out, pgBackup *backup)
|
||||
(uint32) (backup->stop_lsn >> 32),
|
||||
(uint32) backup->stop_lsn);
|
||||
|
||||
time2iso(timestamp, lengthof(timestamp), backup->start_time, false);
|
||||
time2iso(timestamp, lengthof(timestamp), backup->start_time);
|
||||
fprintf(out, "start-time = '%s'\n", timestamp);
|
||||
if (backup->end_time > 0)
|
||||
{
|
||||
time2iso(timestamp, lengthof(timestamp), backup->end_time, false);
|
||||
time2iso(timestamp, lengthof(timestamp), backup->end_time);
|
||||
fprintf(out, "end-time = '%s'\n", timestamp);
|
||||
}
|
||||
fprintf(out, "recovery-xid = " XID_FMT "\n", backup->recovery_xid);
|
||||
if (backup->recovery_time > 0)
|
||||
{
|
||||
time2iso(timestamp, lengthof(timestamp), backup->recovery_time, false);
|
||||
time2iso(timestamp, lengthof(timestamp), backup->recovery_time);
|
||||
fprintf(out, "recovery-time = '%s'\n", timestamp);
|
||||
}
|
||||
|
||||
|
@ -257,7 +257,7 @@ pgBackupDeleteFiles(pgBackup *backup)
|
||||
if (backup->status == BACKUP_STATUS_DELETED)
|
||||
return 0;
|
||||
|
||||
time2iso(timestamp, lengthof(timestamp), backup->recovery_time, true);
|
||||
time2iso(timestamp, lengthof(timestamp), backup->recovery_time);
|
||||
|
||||
elog(INFO, "delete: %s %s", base36enc(backup->start_time), timestamp);
|
||||
|
||||
|
@ -380,8 +380,7 @@ validate_wal(pgBackup *backup,
|
||||
xlogfpath[0] = '\0';
|
||||
|
||||
/* We can restore at least up to the backup end */
|
||||
time2iso(last_timestamp, lengthof(last_timestamp), backup->recovery_time,
|
||||
true);
|
||||
time2iso(last_timestamp, lengthof(last_timestamp), backup->recovery_time);
|
||||
last_xid = backup->recovery_xid;
|
||||
|
||||
if ((TransactionIdIsValid(target_xid) && target_xid == last_xid)
|
||||
@ -431,7 +430,7 @@ validate_wal(pgBackup *backup,
|
||||
|
||||
if (last_time > 0)
|
||||
time2iso(last_timestamp, lengthof(last_timestamp),
|
||||
timestamptz_to_time_t(last_time), true);
|
||||
timestamptz_to_time_t(last_time));
|
||||
|
||||
/* There are all needed WAL records */
|
||||
if (all_wal)
|
||||
@ -460,8 +459,8 @@ validate_wal(pgBackup *backup,
|
||||
last_timestamp, last_xid);
|
||||
|
||||
if (target_time > 0)
|
||||
time2iso(target_timestamp, lengthof(target_timestamp), target_time,
|
||||
true);
|
||||
time2iso(target_timestamp, lengthof(target_timestamp),
|
||||
target_time);
|
||||
if (TransactionIdIsValid(target_xid) && target_time != 0)
|
||||
elog(ERROR, "not enough WAL records to time %s and xid " XID_FMT,
|
||||
target_timestamp, target_xid);
|
||||
|
@ -521,7 +521,7 @@ extern bool wal_contains_lsn(const char *archivedir, XLogRecPtr target_lsn,
|
||||
/* in util.c */
|
||||
extern TimeLineID get_current_timeline(bool safe);
|
||||
extern void sanityChecks(void);
|
||||
extern void time2iso(char *buf, size_t len, time_t time, bool to_local);
|
||||
extern void time2iso(char *buf, size_t len, time_t time);
|
||||
extern const char *status2str(BackupStatus status);
|
||||
extern void remove_trailing_space(char *buf, int comment_mark);
|
||||
extern void remove_not_digit(char *buf, size_t len, const char *str);
|
||||
|
@ -122,8 +122,7 @@ do_restore_or_validate(time_t target_backup_id, pgRecoveryTarget *rt,
|
||||
current_backup = (pgBackup *) parray_get(backups, i);
|
||||
|
||||
/* Skip all backups which started after target backup */
|
||||
if (target_backup_id != INVALID_BACKUP_ID &&
|
||||
current_backup->start_time > target_backup_id)
|
||||
if (target_backup_id && current_backup->start_time > target_backup_id)
|
||||
continue;
|
||||
|
||||
/*
|
||||
@ -382,7 +381,7 @@ restore_backup(pgBackup *backup)
|
||||
"XLOG_BLCKSZ(%d) is not compatible(%d expected)",
|
||||
backup->wal_block_size, XLOG_BLCKSZ);
|
||||
|
||||
time2iso(timestamp, lengthof(timestamp), backup->start_time, true);
|
||||
time2iso(timestamp, lengthof(timestamp), backup->start_time);
|
||||
elog(LOG, "restoring database from backup %s", timestamp);
|
||||
|
||||
/*
|
||||
|
10
src/show.c
10
src/show.c
@ -324,8 +324,7 @@ show_instance_plain(parray *backup_list, bool show_name)
|
||||
char data_bytes_str[10] = "----";
|
||||
|
||||
if (backup->recovery_time != (time_t) 0)
|
||||
time2iso(timestamp, lengthof(timestamp), backup->recovery_time,
|
||||
true);
|
||||
time2iso(timestamp, lengthof(timestamp), backup->recovery_time);
|
||||
if (backup->end_time != (time_t) 0)
|
||||
snprintf(duration, lengthof(duration), "%.*lfs", 0,
|
||||
difftime(backup->end_time, backup->start_time));
|
||||
@ -453,12 +452,12 @@ show_instance_json(parray *backup_list)
|
||||
(uint32) (backup->stop_lsn >> 32), (uint32) backup->stop_lsn);
|
||||
json_add_value(buf, "stop-lsn", lsn, json_level, true);
|
||||
|
||||
time2iso(timestamp, lengthof(timestamp), backup->start_time, true);
|
||||
time2iso(timestamp, lengthof(timestamp), backup->start_time);
|
||||
json_add_value(buf, "start-time", timestamp, json_level, true);
|
||||
|
||||
if (backup->end_time)
|
||||
{
|
||||
time2iso(timestamp, lengthof(timestamp), backup->end_time, true);
|
||||
time2iso(timestamp, lengthof(timestamp), backup->end_time);
|
||||
json_add_value(buf, "end-time", timestamp, json_level, true);
|
||||
}
|
||||
|
||||
@ -467,8 +466,7 @@ show_instance_json(parray *backup_list)
|
||||
|
||||
if (backup->recovery_time > 0)
|
||||
{
|
||||
time2iso(timestamp, lengthof(timestamp), backup->recovery_time,
|
||||
true);
|
||||
time2iso(timestamp, lengthof(timestamp), backup->recovery_time);
|
||||
json_add_value(buf, "recovery-time", timestamp, json_level, true);
|
||||
}
|
||||
|
||||
|
26
src/util.c
26
src/util.c
@ -194,35 +194,31 @@ get_data_checksum_version(bool safe)
|
||||
* Convert time_t value to ISO-8601 format string
|
||||
*/
|
||||
void
|
||||
time2iso(char *buf, size_t len, time_t time, bool to_local)
|
||||
time2iso(char *buf, size_t len, time_t time)
|
||||
{
|
||||
struct tm *ptm = gmtime(&time);
|
||||
time_t gmt = mktime(ptm);
|
||||
time_t offset;
|
||||
|
||||
if (to_local)
|
||||
ptm = localtime(&time);
|
||||
offset = time - gmt + (ptm->tm_isdst ? 3600 : 0);
|
||||
|
||||
strftime(buf, len, "%Y-%m-%d %H:%M:%S", ptm);
|
||||
|
||||
if (offset != 0)
|
||||
{
|
||||
char *ptr = buf;
|
||||
|
||||
ptm = localtime(&time);
|
||||
offset = time - gmt + (ptm->tm_isdst ? 3600 : 0);
|
||||
|
||||
strftime(ptr, len, "%Y-%m-%d %H:%M:%S", ptm);
|
||||
|
||||
ptr += strlen(ptr);
|
||||
snprintf(ptr, len - (ptr - buf), "%c%02d",
|
||||
buf += strlen(buf);
|
||||
sprintf(buf, "%c%02d",
|
||||
(offset >= 0) ? '+' : '-',
|
||||
abs((int) offset) / SECS_PER_HOUR);
|
||||
|
||||
if (abs((int) offset) % SECS_PER_HOUR != 0)
|
||||
{
|
||||
ptr += strlen(ptr);
|
||||
snprintf(ptr, len - (ptr - buf), ":%02d",
|
||||
buf += strlen(buf);
|
||||
sprintf(buf, ":%02d",
|
||||
abs((int) offset % SECS_PER_HOUR) / SECS_PER_MINUTE);
|
||||
}
|
||||
}
|
||||
else
|
||||
strftime(buf, len, "%Y-%m-%d %H:%M:%S+00", ptm);
|
||||
}
|
||||
|
||||
/* copied from timestamp.c */
|
||||
|
Loading…
x
Reference in New Issue
Block a user