@@ -58,7 +58,11 @@ static bool dirExists(const char *path);
5858
5959static void add_files (parray * files ,const char * root ,bool add_root ,bool is_pgdata );
6060static int strCompare (const void * str1 ,const void * str2 );
61- static void create_file_list (parray * files ,const char * root ,const char * prefix ,bool is_append );
61+ static void create_file_list (parray * files ,
62+ const char * root ,
63+ const char * subdir ,
64+ const char * prefix ,
65+ bool is_append );
6266static TimeLineID get_current_timeline (void );
6367
6468/*
@@ -267,7 +271,7 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
267271pg_stop_backup (& current );
268272
269273/* create file list of non-snapshot objects */
270- create_file_list (files ,pgdata ,NULL , false);
274+ create_file_list (files ,pgdata ,DATABASE_FILE_LIST , NULL , false);
271275
272276/* backup files from snapshot volume */
273277for (i = 0 ;i < parray_num (tblspcmp_list );i ++ )
@@ -310,7 +314,8 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
310314/* backup files of DB cluster from snapshot volume */
311315backup_files (mp ,path ,snapshot_files ,prev_files ,lsn ,current .compress_data ,NULL );
312316/* create file list of snapshot objects (DB cluster) */
313- create_file_list (snapshot_files ,mp ,NULL , true);
317+ create_file_list (snapshot_files ,mp ,DATABASE_FILE_LIST ,
318+ NULL , true);
314319/* remove the detected tablespace("PG-DATA") from tblspcmp_list */
315320parray_rm (tblspcmp_list ,"PG-DATA" ,strCompare );
316321i -- ;
@@ -342,8 +347,12 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
342347backup_files (mp ,dest ,snapshot_files ,prev_files ,lsn ,current .compress_data ,prefix );
343348
344349/* create file list of snapshot objects (TABLESPACE) */
345- create_file_list (snapshot_files ,mp ,prefix , true);
346- /* remove the detected tablespace("PG-DATA") from tblspcmp_list */
350+ create_file_list (snapshot_files ,mp ,DATABASE_FILE_LIST ,
351+ prefix , true);
352+ /*
353+ * Remove the detected tablespace("PG-DATA") from
354+ * tblspcmp_list.
355+ */
347356parray_rm (tblspcmp_list ,spcname ,strCompare );
348357i -- ;
349358break ;
@@ -385,7 +394,7 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
385394pg_stop_backup (& current );
386395
387396/* create file list */
388- create_file_list (files ,pgdata ,NULL , false);
397+ create_file_list (files ,pgdata ,DATABASE_FILE_LIST , NULL , false);
389398}
390399
391400/* print summary of size of backup mode files */
@@ -429,7 +438,6 @@ do_backup_arclog(parray *backup_list)
429438int i ;
430439parray * files ;
431440parray * prev_files = NULL ;/* file list of previous database backup */
432- FILE * fp ;
433441char path [MAXPGPATH ];
434442char timeline_dir [MAXPGPATH ];
435443char prev_file_txt [MAXPGPATH ];
@@ -513,19 +521,10 @@ do_backup_arclog(parray *backup_list)
513521backup_files (arclog_path ,path ,files ,prev_files ,NULL ,
514522current .compress_data ,NULL );
515523
516- /* create file list */
517- if (!check )
518- {
519- pgBackupGetPath (& current ,path ,lengthof (path ),ARCLOG_FILE_LIST );
520- fp = fopen (path ,"wt" );
521- if (fp == NULL )
522- elog (ERROR_SYSTEM ,_ ("can't open file list \"%s\": %s" ),path ,
523- strerror (errno ));
524- dir_print_file_list (fp ,files ,arclog_path ,NULL );
525- fclose (fp );
526- }
524+ /* Create file list */
525+ create_file_list (files ,arclog_path ,ARCLOG_FILE_LIST ,NULL , false);
527526
528- /*print summary of size of backup files */
527+ /*Print summary of size of backup files */
529528for (i = 0 ;i < parray_num (files );i ++ )
530529{
531530pgFile * file = (pgFile * )parray_get (files ,i );
@@ -577,7 +576,6 @@ do_backup_srvlog(parray *backup_list)
577576int i ;
578577parray * files ;
579578parray * prev_files = NULL ;/* file list of previous database backup */
580- FILE * fp ;
581579char path [MAXPGPATH ];
582580char prev_file_txt [MAXPGPATH ];
583581pgBackup * prev_backup ;
@@ -623,16 +621,7 @@ do_backup_srvlog(parray *backup_list)
623621backup_files (srvlog_path ,path ,files ,prev_files ,NULL , false,NULL );
624622
625623/* create file list */
626- if (!check )
627- {
628- pgBackupGetPath (& current ,path ,lengthof (path ),SRVLOG_FILE_LIST );
629- fp = fopen (path ,"wt" );
630- if (fp == NULL )
631- elog (ERROR_SYSTEM ,_ ("can't open file list \"%s\": %s" ),path ,
632- strerror (errno ));
633- dir_print_file_list (fp ,files ,srvlog_path ,NULL );
634- fclose (fp );
635- }
624+ create_file_list (files ,arclog_path ,SRVLOG_FILE_LIST ,NULL , false);
636625
637626/* print summary of size of backup mode files */
638627for (i = 0 ;i < parray_num (files );i ++ )
@@ -1548,18 +1537,22 @@ strCompare(const void *str1, const void *str2)
15481537}
15491538
15501539/*
1551- * Output the list ofbackup files to backup catalog
1540+ * Output the list of files to backup catalog
15521541 */
15531542static void
1554- create_file_list (parray * files ,const char * root ,const char * prefix ,bool is_append )
1543+ create_file_list (parray * files ,
1544+ const char * root ,
1545+ const char * subdir ,
1546+ const char * prefix ,
1547+ bool is_append )
15551548{
15561549FILE * fp ;
15571550char path [MAXPGPATH ];
15581551
15591552if (!check )
15601553{
15611554/* output path is '$BACKUP_PATH/file_database.txt' */
1562- pgBackupGetPath (& current ,path ,lengthof (path ),DATABASE_FILE_LIST );
1555+ pgBackupGetPath (& current ,path ,lengthof (path ),subdir );
15631556fp = fopen (path ,is_append ?"at" :"wt" );
15641557if (fp == NULL )
15651558elog (ERROR_SYSTEM ,_ ("can't open file list \"%s\": %s" ),path ,