@@ -168,6 +168,8 @@ merge_backups(pgBackup *to_backup, pgBackup *from_backup)
168
168
merge_files_arg * threads_args = NULL ;
169
169
int i ;
170
170
bool merge_isok = true;
171
+ int64 to_data_bytes ,
172
+ to_wal_bytes ;
171
173
172
174
elog (INFO , "Merging backup %s with backup %s" , from_backup_id , to_backup_id );
173
175
@@ -282,26 +284,28 @@ merge_backups(pgBackup *to_backup, pgBackup *from_backup)
282
284
*/
283
285
to_backup -> status = BACKUP_STATUS_OK ;
284
286
/* Compute summary of size of regular files in the backup */
285
- to_backup -> data_bytes = 0 ;
287
+ to_data_bytes = 0 ;
286
288
for (i = 0 ; i < parray_num (files ); i ++ )
287
289
{
288
290
pgFile * file = (pgFile * ) parray_get (files , i );
289
291
290
292
if (S_ISDIR (file -> mode ))
291
- to_backup -> data_bytes += 4096 ;
293
+ to_data_bytes += 4096 ;
292
294
/* Count the amount of the data actually copied */
293
295
else if (S_ISREG (file -> mode ))
294
- to_backup -> data_bytes += file -> write_size ;
296
+ to_data_bytes += file -> write_size ;
295
297
}
296
298
/* compute size of wal files of this backup stored in the archive */
297
299
if (!to_backup -> stream )
298
- to_backup -> wal_bytes = instance_config .xlog_seg_size *
300
+ to_wal_bytes = instance_config .xlog_seg_size *
299
301
(to_backup -> stop_lsn / instance_config .xlog_seg_size -
300
302
to_backup -> start_lsn / instance_config .xlog_seg_size + 1 );
301
303
else
302
- to_backup -> wal_bytes = BYTES_INVALID ;
304
+ to_wal_bytes = BYTES_INVALID ;
303
305
304
306
write_backup_filelist (to_backup , files , from_database_path );
307
+ to_backup -> data_bytes = to_data_bytes ;
308
+ to_backup -> wal_bytes = to_wal_bytes ;
305
309
write_backup (to_backup );
306
310
307
311
delete_source_backup :
@@ -314,6 +318,7 @@ merge_backups(pgBackup *to_backup, pgBackup *from_backup)
314
318
/*
315
319
* Delete files which are not in from_backup file list.
316
320
*/
321
+ parray_qsort (files , pgFileComparePathDesc );
317
322
for (i = 0 ; i < parray_num (to_files ); i ++ )
318
323
{
319
324
pgFile * file = (pgFile * ) parray_get (to_files , i );
@@ -341,6 +346,9 @@ merge_backups(pgBackup *to_backup, pgBackup *from_backup)
341
346
to_backup -> backup_mode = BACKUP_MODE_FULL ;
342
347
to_backup -> status = BACKUP_STATUS_OK ;
343
348
to_backup -> parent_backup = INVALID_BACKUP_ID ;
349
+ /* Restore sizes */
350
+ to_backup -> data_bytes = to_data_bytes ;
351
+ to_backup -> wal_bytes = to_wal_bytes ;
344
352
write_backup (to_backup );
345
353
346
354
/* Cleanup */
0 commit comments