@@ -664,8 +664,8 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync, bool
664664
665665 for (i = 0 ; i < parray_num (backup_files_list ); i ++ )
666666 {
667- char to_fullpath [MAXPGPATH ];
668- pgFile * file = (pgFile * ) parray_get (backup_files_list , i );
667+ char to_fullpath [MAXPGPATH ];
668+ pgFile * file = (pgFile * ) parray_get (backup_files_list , i );
669669
670670 /* TODO: sync directory ? */
671671 if (S_ISDIR (file -> mode ))
@@ -687,7 +687,21 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync, bool
687687 }
688688
689689 if (fio_sync (to_fullpath , FIO_BACKUP_HOST ) != 0 )
690- elog (ERROR , "Failed to sync file \"%s\": %s" , to_fullpath , strerror (errno ));
690+ elog (ERROR , "Cannot sync file \"%s\": %s" , to_fullpath , strerror (errno ));
691+
692+ /* fsync header file */
693+ if (file -> external_dir_num == 0 &&
694+ file -> is_datafile && !file -> is_cfs &&
695+ file -> n_headers > 0 )
696+ {
697+ char to_fullpath_hdr [MAXPGPATH ];
698+
699+ snprintf (to_fullpath_hdr , MAXPGPATH , "%s_hdr" , to_fullpath );
700+
701+ if (fio_sync (to_fullpath , FIO_BACKUP_HOST ) != 0 )
702+ elog (ERROR , "Cannot sync file \"%s\": %s" , to_fullpath_hdr , strerror (errno ));
703+
704+ }
691705 }
692706
693707 time (& end_time );
@@ -2131,7 +2145,7 @@ backup_files(void *arg)
21312145 /* backup file */
21322146 if (file -> is_datafile && !file -> is_cfs )
21332147 {
2134- backup_data_file (& (arguments -> conn_arg ), file , from_fullpath , to_fullpath ,
2148+ backup_data_file_new (& (arguments -> conn_arg ), file , from_fullpath , to_fullpath ,
21352149 arguments -> prev_start_lsn ,
21362150 current .backup_mode ,
21372151 instance_config .compress_alg ,
@@ -2147,12 +2161,6 @@ backup_files(void *arg)
21472161 current .backup_mode , current .parent_backup , true);
21482162 }
21492163
2150- /* No point in storing empty, missing or not changed files */
2151- if (file -> write_size <= 0 )
2152- unlink (to_fullpath );
2153- // elog(ERROR, "Cannot remove file \"%s\": %s", to_fullpath,
2154- // strerror(errno));
2155-
21562164 if (file -> write_size == FILE_NOT_FOUND )
21572165 continue ;
21582166
0 commit comments