@@ -270,6 +270,9 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync, bool
270270 pgBackupGetPath (& current , external_prefix , lengthof (external_prefix ),
271271 EXTERNAL_DIR );
272272
273+ /* initialize backup's file list */
274+ backup_files_list = parray_new ();
275+
273276 /* start stream replication */
274277 if (stream_wal )
275278 {
@@ -280,9 +283,6 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync, bool
280283 current .start_lsn , current .tli );
281284 }
282285
283- /* initialize backup list */
284- backup_files_list = parray_new ();
285-
286286 /* list files with the logical path. omit $PGDATA */
287287 if (fio_is_remote (FIO_DB_HOST ))
288288 fio_list_dir (backup_files_list , instance_config .pgdata ,
@@ -567,52 +567,11 @@ do_backup_instance(PGconn *backup_conn, PGNodeInfo *nodeInfo, bool no_sync, bool
567567 /* close ssh session in main thread */
568568 fio_disconnect ();
569569
570- /* Add archived xlog files into the list of files of this backup */
571- if (stream_wal )
572- {
573- parray * xlog_files_list ;
574- char pg_xlog_path [MAXPGPATH ];
575- char wal_full_path [MAXPGPATH ];
576-
577- /* Scan backup PG_XLOG_DIR */
578- xlog_files_list = parray_new ();
579- join_path_components (pg_xlog_path , database_path , PG_XLOG_DIR );
580- dir_list_file (xlog_files_list , pg_xlog_path , false, true, false, false, true, 0 ,
581- FIO_BACKUP_HOST );
582-
583- /* TODO: Drop streamed WAL segments greater than stop_lsn */
584- for (i = 0 ; i < parray_num (xlog_files_list ); i ++ )
585- {
586- pgFile * file = (pgFile * ) parray_get (xlog_files_list , i );
587-
588- join_path_components (wal_full_path , pg_xlog_path , file -> rel_path );
589-
590- if (!S_ISREG (file -> mode ))
591- continue ;
592-
593- file -> crc = pgFileGetCRC (wal_full_path , true, false);
594- file -> write_size = file -> size ;
595-
596- /* overwrite rel_path, because now it is relative to
597- * /backup_dir/backups/instance_name/backup_id/database/pg_xlog/
598- */
599- pg_free (file -> rel_path );
600-
601- /* Now it is relative to /backup_dir/backups/instance_name/backup_id/database/ */
602- file -> rel_path = pgut_strdup (GetRelativePath (wal_full_path , database_path ));
603-
604- file -> name = last_dir_separator (file -> rel_path );
605-
606- if (file -> name == NULL ) // TODO: do it in pgFileInit
607- file -> name = file -> rel_path ;
608- else
609- file -> name ++ ;
610- }
570+ /*
571+ * Add archived xlog files into the list of files of this backup
572+ * NOTHING TO DO HERE
573+ */
611574
612- /* Add xlog files into the list of backed up files */
613- parray_concat (backup_files_list , xlog_files_list );
614- parray_free (xlog_files_list );
615- }
616575
617576 /* write database map to file and add it to control file */
618577 if (database_map )
@@ -1920,7 +1879,10 @@ pg_stop_backup(pgBackup *backup, PGconn *pg_startbackup_conn,
19201879
19211880 if (stream_wal )
19221881 {
1923- wait_WAL_streaming_end ();
1882+ /* This function will also add list of xlog files
1883+ * to the passed filelist */
1884+ if (wait_WAL_streaming_end (backup_files_list ))
1885+ elog (ERROR , "WAL streaming failed" );
19241886
19251887 pgBackupGetPath2 (backup , stream_xlog_path ,
19261888 lengthof (stream_xlog_path ),
0 commit comments