@@ -58,7 +58,11 @@ static bool dirExists(const char *path);
58
58
59
59
static void add_files (parray * files ,const char * root ,bool add_root ,bool is_pgdata );
60
60
static 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 );
62
66
static TimeLineID get_current_timeline (void );
63
67
64
68
/*
@@ -267,7 +271,7 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
267
271
pg_stop_backup (& current );
268
272
269
273
/* 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);
271
275
272
276
/* backup files from snapshot volume */
273
277
for (i = 0 ;i < parray_num (tblspcmp_list );i ++ )
@@ -310,7 +314,8 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
310
314
/* backup files of DB cluster from snapshot volume */
311
315
backup_files (mp ,path ,snapshot_files ,prev_files ,lsn ,current .compress_data ,NULL );
312
316
/* 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);
314
319
/* remove the detected tablespace("PG-DATA") from tblspcmp_list */
315
320
parray_rm (tblspcmp_list ,"PG-DATA" ,strCompare );
316
321
i -- ;
@@ -342,8 +347,12 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
342
347
backup_files (mp ,dest ,snapshot_files ,prev_files ,lsn ,current .compress_data ,prefix );
343
348
344
349
/* 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
+ */
347
356
parray_rm (tblspcmp_list ,spcname ,strCompare );
348
357
i -- ;
349
358
break ;
@@ -385,7 +394,7 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
385
394
pg_stop_backup (& current );
386
395
387
396
/* create file list */
388
- create_file_list (files ,pgdata ,NULL , false);
397
+ create_file_list (files ,pgdata ,DATABASE_FILE_LIST , NULL , false);
389
398
}
390
399
391
400
/* print summary of size of backup mode files */
@@ -429,7 +438,6 @@ do_backup_arclog(parray *backup_list)
429
438
int i ;
430
439
parray * files ;
431
440
parray * prev_files = NULL ;/* file list of previous database backup */
432
- FILE * fp ;
433
441
char path [MAXPGPATH ];
434
442
char timeline_dir [MAXPGPATH ];
435
443
char prev_file_txt [MAXPGPATH ];
@@ -513,19 +521,10 @@ do_backup_arclog(parray *backup_list)
513
521
backup_files (arclog_path ,path ,files ,prev_files ,NULL ,
514
522
current .compress_data ,NULL );
515
523
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);
527
526
528
- /*print summary of size of backup files */
527
+ /*Print summary of size of backup files */
529
528
for (i = 0 ;i < parray_num (files );i ++ )
530
529
{
531
530
pgFile * file = (pgFile * )parray_get (files ,i );
@@ -577,7 +576,6 @@ do_backup_srvlog(parray *backup_list)
577
576
int i ;
578
577
parray * files ;
579
578
parray * prev_files = NULL ;/* file list of previous database backup */
580
- FILE * fp ;
581
579
char path [MAXPGPATH ];
582
580
char prev_file_txt [MAXPGPATH ];
583
581
pgBackup * prev_backup ;
@@ -623,16 +621,7 @@ do_backup_srvlog(parray *backup_list)
623
621
backup_files (srvlog_path ,path ,files ,prev_files ,NULL , false,NULL );
624
622
625
623
/* 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);
636
625
637
626
/* print summary of size of backup mode files */
638
627
for (i = 0 ;i < parray_num (files );i ++ )
@@ -1548,18 +1537,22 @@ strCompare(const void *str1, const void *str2)
1548
1537
}
1549
1538
1550
1539
/*
1551
- * Output the list ofbackup files to backup catalog
1540
+ * Output the list of files to backup catalog
1552
1541
*/
1553
1542
static 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 )
1555
1548
{
1556
1549
FILE * fp ;
1557
1550
char path [MAXPGPATH ];
1558
1551
1559
1552
if (!check )
1560
1553
{
1561
1554
/* output path is '$BACKUP_PATH/file_database.txt' */
1562
- pgBackupGetPath (& current ,path ,lengthof (path ),DATABASE_FILE_LIST );
1555
+ pgBackupGetPath (& current ,path ,lengthof (path ),subdir );
1563
1556
fp = fopen (path ,is_append ?"at" :"wt" );
1564
1557
if (fp == NULL )
1565
1558
elog (ERROR_SYSTEM ,_ ("can't open file list \"%s\": %s" ),path ,