@@ -123,11 +123,11 @@ typedef struct TablespaceCreatedList
123
123
124
124
static int pgCompareString (const void * str1 , const void * str2 );
125
125
126
- static char dir_check_file (pgFile * file );
126
+ static char dir_check_file (pgFile * file , bool backup_logs );
127
127
128
128
static void dir_list_file_internal (parray * files , pgFile * parent , const char * parent_dir ,
129
- bool exclude , bool follow_symlink , bool skip_hidden ,
130
- int external_dir_num , fio_location location );
129
+ bool exclude , bool follow_symlink , bool backup_logs ,
130
+ bool skip_hidden , int external_dir_num , fio_location location );
131
131
static void opt_path_map (ConfigOption * opt , const char * arg ,
132
132
TablespaceList * list , const char * type );
133
133
@@ -561,17 +561,6 @@ dir_list_file(parray *files, const char *root, bool exclude, bool follow_symlink
561
561
return ;
562
562
}
563
563
564
- /* setup exclusion list for file search */
565
- if (!backup_logs )
566
- {
567
- int i ;
568
-
569
- for (i = 0 ; pgdata_exclude_dir [i ]; i ++ ); /* find first empty slot */
570
-
571
- /* Set 'pg_log' in first empty slot */
572
- pgdata_exclude_dir [i ] = PG_LOG_DIR ;
573
- }
574
-
575
564
if (!S_ISDIR (file -> mode ))
576
565
{
577
566
if (external_dir_num > 0 )
@@ -585,7 +574,7 @@ dir_list_file(parray *files, const char *root, bool exclude, bool follow_symlink
585
574
parray_append (files , file );
586
575
587
576
dir_list_file_internal (files , file , root , exclude , follow_symlink ,
588
- skip_hidden , external_dir_num , location );
577
+ backup_logs , skip_hidden , external_dir_num , location );
589
578
590
579
if (!add_root )
591
580
pgFileFree (file );
@@ -609,7 +598,7 @@ dir_list_file(parray *files, const char *root, bool exclude, bool follow_symlink
609
598
* - datafiles
610
599
*/
611
600
static char
612
- dir_check_file (pgFile * file )
601
+ dir_check_file (pgFile * file , bool backup_logs )
613
602
{
614
603
int i ;
615
604
int sscanf_res ;
@@ -623,7 +612,7 @@ dir_check_file(pgFile *file)
623
612
if (!exclusive_backup )
624
613
{
625
614
for (i = 0 ; pgdata_exclude_files_non_exclusive [i ]; i ++ )
626
- if (strcmp (file -> name ,
615
+ if (strcmp (file -> rel_path ,
627
616
pgdata_exclude_files_non_exclusive [i ]) == 0 )
628
617
{
629
618
/* Skip */
@@ -633,7 +622,7 @@ dir_check_file(pgFile *file)
633
622
}
634
623
635
624
for (i = 0 ; pgdata_exclude_files [i ]; i ++ )
636
- if (strcmp (file -> name , pgdata_exclude_files [i ]) == 0 )
625
+ if (strcmp (file -> rel_path , pgdata_exclude_files [i ]) == 0 )
637
626
{
638
627
/* Skip */
639
628
elog (VERBOSE , "Excluding file: %s" , file -> name );
@@ -660,6 +649,16 @@ dir_check_file(pgFile *file)
660
649
return CHECK_EXCLUDE_FALSE ;
661
650
}
662
651
}
652
+
653
+ if (!backup_logs )
654
+ {
655
+ if (strcmp (file -> rel_path , PG_LOG_DIR ) == 0 )
656
+ {
657
+ /* Skip */
658
+ elog (VERBOSE , "Excluding directory content: %s" , file -> rel_path );
659
+ return CHECK_EXCLUDE_FALSE ;
660
+ }
661
+ }
663
662
}
664
663
665
664
/*
@@ -807,8 +806,8 @@ dir_check_file(pgFile *file)
807
806
*/
808
807
static void
809
808
dir_list_file_internal (parray * files , pgFile * parent , const char * parent_dir ,
810
- bool exclude , bool follow_symlink , bool skip_hidden ,
811
- int external_dir_num , fio_location location )
809
+ bool exclude , bool follow_symlink , bool backup_logs ,
810
+ bool skip_hidden , int external_dir_num , fio_location location )
812
811
{
813
812
DIR * dir ;
814
813
struct dirent * dent ;
@@ -874,7 +873,7 @@ dir_list_file_internal(parray *files, pgFile *parent, const char *parent_dir,
874
873
875
874
if (exclude )
876
875
{
877
- check_res = dir_check_file (file );
876
+ check_res = dir_check_file (file , backup_logs );
878
877
if (check_res == CHECK_FALSE )
879
878
{
880
879
/* Skip */
@@ -897,7 +896,7 @@ dir_list_file_internal(parray *files, pgFile *parent, const char *parent_dir,
897
896
*/
898
897
if (S_ISDIR (file -> mode ))
899
898
dir_list_file_internal (files , file , child , exclude , follow_symlink ,
900
- skip_hidden , external_dir_num , location );
899
+ backup_logs , skip_hidden , external_dir_num , location );
901
900
}
902
901
903
902
if (errno && errno != ENOENT )
@@ -1288,7 +1287,7 @@ check_tablespace_mapping(pgBackup *backup, bool incremental, bool *tblspaces_are
1288
1287
}
1289
1288
1290
1289
void
1291
- check_external_dir_mapping (pgBackup * backup )
1290
+ check_external_dir_mapping (pgBackup * backup , bool incremental )
1292
1291
{
1293
1292
TablespaceListCell * cell ;
1294
1293
parray * external_dirs_to_restore ;
@@ -1341,7 +1340,7 @@ check_external_dir_mapping(pgBackup *backup)
1341
1340
char * external_dir = (char * ) parray_get (external_dirs_to_restore ,
1342
1341
i );
1343
1342
1344
- if (!dir_is_empty (external_dir , FIO_DB_HOST ))
1343
+ if (!incremental && ! dir_is_empty (external_dir , FIO_DB_HOST ))
1345
1344
elog (ERROR , "External directory is not empty: \"%s\"" ,
1346
1345
external_dir );
1347
1346
}
0 commit comments