@@ -44,6 +44,7 @@ typedef struct
44
44
parray * dbOid_exclude_list ;
45
45
bool skip_external_dirs ;
46
46
const char * to_root ;
47
+ size_t restored_bytes ;
47
48
48
49
/*
49
50
* Return value from the thread.
@@ -524,6 +525,11 @@ restore_chain(pgBackup *dest_backup, parray *parent_chain,
524
525
restore_files_arg_new * threads_args ;
525
526
bool restore_isok = true;
526
527
528
+ /* fancy reporting */
529
+ char pretty_dest_bytes [20 ];
530
+ char pretty_total_bytes [20 ];
531
+ size_t dest_bytes = 0 ;
532
+ size_t total_bytes = 0 ;
527
533
char pretty_time [20 ];
528
534
time_t start_time , end_time ;
529
535
@@ -608,6 +614,9 @@ restore_chain(pgBackup *dest_backup, parray *parent_chain,
608
614
{
609
615
pgFile * file = (pgFile * ) parray_get (dest_files , i );
610
616
617
+ if (S_ISDIR (file -> mode ))
618
+ total_bytes += 4096 ;
619
+
611
620
if (!params -> skip_external_dirs &&
612
621
file -> external_dir_num && S_ISDIR (file -> mode ))
613
622
{
@@ -639,9 +648,15 @@ restore_chain(pgBackup *dest_backup, parray *parent_chain,
639
648
num_threads );
640
649
641
650
/* Restore files into target directory */
642
- thread_interrupted = false;
643
- elog (INFO , "Start restoring backup files" );
651
+ if (dest_backup -> stream )
652
+ dest_bytes = dest_backup -> pgdata_bytes + dest_backup -> wal_bytes ;
653
+ else
654
+ dest_bytes = dest_backup -> pgdata_bytes ;
655
+
656
+ pretty_size (dest_bytes , pretty_dest_bytes , lengthof (pretty_dest_bytes ));
657
+ elog (INFO , "Start restoring backup files. PGDATA size: %s" , pretty_dest_bytes );
644
658
time (& start_time );
659
+ thread_interrupted = false;
645
660
for (i = 0 ; i < num_threads ; i ++ )
646
661
{
647
662
restore_files_arg_new * arg = & (threads_args [i ]);
@@ -653,6 +668,7 @@ restore_chain(pgBackup *dest_backup, parray *parent_chain,
653
668
arg -> dbOid_exclude_list = dbOid_exclude_list ;
654
669
arg -> skip_external_dirs = params -> skip_external_dirs ;
655
670
arg -> to_root = pgdata_path ;
671
+ threads_args [i ].restored_bytes = 0 ;
656
672
/* By default there are some error */
657
673
threads_args [i ].ret = 1 ;
658
674
@@ -668,15 +684,27 @@ restore_chain(pgBackup *dest_backup, parray *parent_chain,
668
684
pthread_join (threads [i ], NULL );
669
685
if (threads_args [i ].ret == 1 )
670
686
restore_isok = false;
687
+
688
+ total_bytes += threads_args [i ].restored_bytes ;
671
689
}
672
690
673
691
time (& end_time );
674
692
pretty_time_interval (difftime (end_time , start_time ),
675
693
pretty_time , lengthof (pretty_time ));
694
+ pretty_size (total_bytes , pretty_total_bytes , lengthof (pretty_total_bytes ));
695
+
676
696
if (restore_isok )
677
- elog (INFO , "Backup files are restored, time elapsed: %s" , pretty_time );
697
+ {
698
+ elog (INFO , "Backup files are restored. Transfered bytes: %s, time elapsed: %s" ,
699
+ pretty_total_bytes , pretty_time );
700
+
701
+ elog (INFO , "Approximate restore efficiency ratio: %.f%% (%s/%s)" ,
702
+ ((float ) dest_bytes / total_bytes ) * 100 ,
703
+ pretty_dest_bytes , pretty_total_bytes );
704
+ }
678
705
else
679
- elog (ERROR , "Backup files restoring failed, time elapsed: %s" , pretty_time );
706
+ elog (ERROR , "Backup files restoring failed. Transfered bytes: %s, time elapsed: %s" ,
707
+ pretty_total_bytes , pretty_time );
680
708
681
709
if (no_sync )
682
710
elog (WARNING , "Restored files are not synced to disk" );
@@ -841,11 +869,12 @@ restore_files_new(void *arg)
841
869
/* Restore destination file */
842
870
if (dest_file -> is_datafile && !dest_file -> is_cfs )
843
871
/* Destination file is data file */
844
- restore_data_file_new (arguments -> parent_chain , dest_file , out , to_fullpath );
872
+ arguments -> restored_bytes += restore_data_file_new (arguments -> parent_chain ,
873
+ dest_file , out , to_fullpath );
845
874
else
846
875
/* Destination file is non-data file */
847
- restore_non_data_file ( arguments -> parent_chain , arguments -> dest_backup ,
848
- dest_file , out , to_fullpath );
876
+ arguments -> restored_bytes += restore_non_data_file ( arguments -> parent_chain ,
877
+ arguments -> dest_backup , dest_file , out , to_fullpath );
849
878
850
879
/*
851
880
* Destination file is data file.
@@ -875,11 +904,6 @@ restore_files_new(void *arg)
875
904
if (fio_fclose (out ) != 0 )
876
905
elog (ERROR , "Cannot close file \"%s\": %s" , to_fullpath ,
877
906
strerror (errno ));
878
-
879
- /* print size of restored file */
880
- // if (file->write_size != BYTES_INVALID)
881
- // elog(VERBOSE, "Restored file %s : " INT64_FORMAT " bytes",
882
- // file->path, file->write_size);
883
907
}
884
908
885
909
/* Data files restoring is successful */
0 commit comments