@@ -654,7 +654,7 @@ write_backup_filelist(pgBackup *backup, parray *files, const char *root,
654654while (i < parray_num (files ))
655655{
656656pgFile * file = (pgFile * )parray_get (files ,i );
657- char * path = file -> path ;
657+ char * path = file -> path ;/* for streamed WAL files */
658658char line [BLCKSZ ];
659659int len = 0 ;
660660
@@ -667,13 +667,13 @@ write_backup_filelist(pgBackup *backup, parray *files, const char *root,
667667if (S_ISREG (file -> mode )&& file -> write_size > 0 )
668668backup_size_on_disk += file -> write_size ;
669669
670- if ( file -> external_dir_num && external_list )
671- {
672- path = GetRelativePath ( path , parray_get ( external_list ,
673- file -> external_dir_num - 1 ));
674- }
675- else
676- path = file -> rel_path ;
670+ /* for files from PGDATA and external files use rel_path
671+ * streamed WAL files has rel_path relative not to "database/"
672+ * but to "database/pg_wal", so for them use path.
673+ */
674+ if (( root && strstr ( path , root ) == path ) ||
675+ ( file -> external_dir_num && external_list ))
676+ path = file -> rel_path ;
677677
678678len = sprintf (line ,"{\"path\":\"%s\", \"size\":\"" INT64_FORMAT "\", "
679679"\"mode\":\"%u\", \"is_datafile\":\"%u\", "