Skip to content

Commit 5ed9444

Browse files
committed
bugfix: correctly calculate wal-bytes for STREAM backups
1 parent 9622b23 commit 5ed9444

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

src/backup.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,10 +642,15 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync, bool
642642
*/
643643
pg_free(file->rel_path);
644644

645+
/* Now it is relative to /backup_dir/backups/instance_name/backup_id/database/ */
645646
file->rel_path = pgut_strdup(GetRelativePath(wal_full_path, database_path));
647+
646648
file->name = last_dir_separator(file->rel_path);
647649

648-
/* Now it is relative to /backup_dir/backups/instance_name/backup_id/database/ */
650+
if (file->name == NULL)
651+
file->name = file->rel_path;
652+
else
653+
file->name++;
649654
}
650655

651656
/* Add xlog files into the list of backed up files */

src/catalog.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1880,7 +1880,7 @@ write_backup_filelist(pgBackup *backup, parray *files, const char *root,
18801880
* Size of WAL files in 'pg_wal' is counted separately
18811881
* TODO: in 3.0 add attribute is_walfile
18821882
*/
1883-
if (IsXLogFileName(file->name) && (file->external_dir_num == 0))
1883+
if (IsXLogFileName(file->name) && file->external_dir_num == 0)
18841884
wal_size_on_disk += file->write_size;
18851885
else
18861886
{

src/data.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2230,6 +2230,8 @@ get_data_file_headers(HeaderMap *hdr_map, pgFile *file, uint32 backup_version, b
22302230
return headers;
22312231
}
22322232

2233+
/* write headers of all blocks belonging to file to header map and
2234+
* save its offset and size */
22332235
void
22342236
write_page_headers(BackupPageHeader2 *headers, pgFile *file, HeaderMap *hdr_map, bool is_merge)
22352237
{

0 commit comments

Comments
 (0)