@@ -983,14 +983,18 @@ restore_chain(pgBackup *dest_backup, parray *parent_chain,
983983search_key .rel_path = XLOG_CONTROL_FILE ;
984984search_key .external_dir_num = 0 ;
985985control_file_elem_index = parray_bsearch_index (dest_files ,& search_key ,pgFileCompareRelPathWithExternal );
986- if (control_file_elem_index < 0 )
987- elog (ERROR ,"\"%s\" not found in backup %s" ,XLOG_CONTROL_FILE ,base36enc (dest_backup -> start_time ));
986+
987+ if (control_file_elem_index < 0 )
988+ elog (ERROR ,"File \"%s\" not found in backup %s" ,XLOG_CONTROL_FILE ,base36enc (dest_backup -> start_time ));
988989dest_pg_control_file = parray_remove (dest_files ,control_file_elem_index );
989990
990991join_path_components (dest_pg_control_fullpath ,pgdata_path ,dest_pg_control_file -> rel_path );
991992/* remove dest control file before restoring */
992993if (params -> incremental_mode != INCR_NONE )
993994fio_unlink (dest_pg_control_fullpath ,FIO_DB_HOST );
995+
996+ // TODO: maybe we should rename "pg_control" into something like "pg_control.pbk" to
997+ // keep the ability to rerun failed incremental restore ?
994998}
995999
9961000elog (INFO ,"Start restoring backup files. PGDATA size: %s" ,pretty_dest_bytes );
@@ -1036,7 +1040,6 @@ restore_chain(pgBackup *dest_backup, parray *parent_chain,
10361040/* [Issue #313] copy pg_control at very end */
10371041if (restore_isok )
10381042{
1039- fio_is_remote (FIO_DB_HOST );/* reopen already closed ssh connection */
10401043total_bytes += restore_file (dest_pg_control_file ,dest_pg_control_fullpath , false,NULL ,
10411044dest_backup ,parent_chain ,use_bitmap ,params -> incremental_mode ,params -> shift_lsn );
10421045fio_disconnect ();
@@ -1103,7 +1106,6 @@ restore_chain(pgBackup *dest_backup, parray *parent_chain,
11031106}
11041107
11051108/* TODO: write test for case: file to be synced is missing */
1106- /* MKulagin question: where is fio connection reopened? */
11071109if (fio_sync (to_fullpath ,FIO_DB_HOST )!= 0 )
11081110elog (ERROR ,"Failed to sync file \"%s\": %s" ,to_fullpath ,strerror (errno ));
11091111}