@@ -155,6 +155,7 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo)
155155
156156 /* for fancy reporting */
157157 time_t start_time , end_time ;
158+ char pretty_bytes [20 ];
158159
159160 elog (LOG , "Database backup start" );
160161 if (current .external_dir_str )
@@ -330,6 +331,20 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo)
330331 elog (ERROR , "PGDATA is almost empty. Either it was concurrently deleted or "
331332 "pg_probackup do not possess sufficient permissions to list PGDATA content" );
332333
334+ /* Calculate pgdata_bytes */
335+ for (i = 0 ; i < parray_num (backup_files_list ); i ++ )
336+ {
337+ pgFile * file = (pgFile * ) parray_get (backup_files_list , i );
338+
339+ if (file -> external_dir_num != 0 )
340+ continue ;
341+
342+ current .pgdata_bytes += file -> size ;
343+ }
344+
345+ pretty_size (current .pgdata_bytes , pretty_bytes , lengthof (pretty_bytes ));
346+ elog (INFO , "PGDATA size: %s" , pretty_bytes );
347+
333348 /*
334349 * Sort pathname ascending. It is necessary to create intermediate
335350 * directories sequentially.
@@ -547,22 +562,6 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo)
547562 /* close ssh session in main thread */
548563 fio_disconnect ();
549564
550- /* Calculate pgdata_bytes */
551- for (i = 0 ; i < parray_num (backup_files_list ); i ++ )
552- {
553- pgFile * file = (pgFile * ) parray_get (backup_files_list , i );
554-
555- /* In case of FULL or DELTA backup we can trust read_size.
556- * In case of PAGE or PTRACK we are forced to trust datafile size,
557- * taken at the start of backup.
558- */
559- if (current .backup_mode == BACKUP_MODE_FULL ||
560- current .backup_mode == BACKUP_MODE_DIFF_DELTA )
561- current .pgdata_bytes += file -> read_size ;
562- else
563- current .pgdata_bytes += file -> size ;
564- }
565-
566565 /* Add archived xlog files into the list of files of this backup */
567566 if (stream_wal )
568567 {
699698do_backup (time_t start_time , bool no_validate ,
700699 pgSetBackupParams * set_backup_params )
701700{
702- PGconn * backup_conn = NULL ;
703- PGNodeInfo nodeInfo ;
704- char pretty_data_bytes [20 ];
701+ PGconn * backup_conn = NULL ;
702+ PGNodeInfo nodeInfo ;
703+ char pretty_bytes [20 ];
705704
706705 /* Initialize PGInfonode */
707706 pgNodeInit (& nodeInfo );
@@ -836,10 +835,10 @@ do_backup(time_t start_time, bool no_validate,
836835
837836 /* Notify user about backup size */
838837 if (current .stream )
839- pretty_size (current .data_bytes + current .wal_bytes , pretty_data_bytes , lengthof (pretty_data_bytes ));
838+ pretty_size (current .data_bytes + current .wal_bytes , pretty_bytes , lengthof (pretty_bytes ));
840839 else
841- pretty_size (current .data_bytes , pretty_data_bytes , lengthof (pretty_data_bytes ));
842- elog (INFO , "Backup %s resident size: %s" , base36enc (current .start_time ), pretty_data_bytes );
840+ pretty_size (current .data_bytes , pretty_bytes , lengthof (pretty_bytes ));
841+ elog (INFO , "Backup %s resident size: %s" , base36enc (current .start_time ), pretty_bytes );
843842
844843 if (current .status == BACKUP_STATUS_OK ||
845844 current .status == BACKUP_STATUS_DONE )
0 commit comments