@@ -123,11 +123,11 @@ typedef struct TablespaceCreatedList
123123
124124static int pgCompareString (const void * str1 , const void * str2 );
125125
126- static char dir_check_file (pgFile * file );
126+ static char dir_check_file (pgFile * file , bool backup_logs );
127127
128128static 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 );
131131static void opt_path_map (ConfigOption * opt , const char * arg ,
132132 TablespaceList * list , const char * type );
133133
@@ -561,17 +561,6 @@ dir_list_file(parray *files, const char *root, bool exclude, bool follow_symlink
561561 return ;
562562 }
563563
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-
575564 if (!S_ISDIR (file -> mode ))
576565 {
577566 if (external_dir_num > 0 )
@@ -585,7 +574,7 @@ dir_list_file(parray *files, const char *root, bool exclude, bool follow_symlink
585574 parray_append (files , file );
586575
587576 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 );
589578
590579 if (!add_root )
591580 pgFileFree (file );
@@ -609,7 +598,7 @@ dir_list_file(parray *files, const char *root, bool exclude, bool follow_symlink
609598 * - datafiles
610599 */
611600static char
612- dir_check_file (pgFile * file )
601+ dir_check_file (pgFile * file , bool backup_logs )
613602{
614603 int i ;
615604 int sscanf_res ;
@@ -623,7 +612,7 @@ dir_check_file(pgFile *file)
623612 if (!exclusive_backup )
624613 {
625614 for (i = 0 ; pgdata_exclude_files_non_exclusive [i ]; i ++ )
626- if (strcmp (file -> name ,
615+ if (strcmp (file -> rel_path ,
627616 pgdata_exclude_files_non_exclusive [i ]) == 0 )
628617 {
629618 /* Skip */
@@ -633,7 +622,7 @@ dir_check_file(pgFile *file)
633622 }
634623
635624 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 )
637626 {
638627 /* Skip */
639628 elog (VERBOSE , "Excluding file: %s" , file -> name );
@@ -660,6 +649,16 @@ dir_check_file(pgFile *file)
660649 return CHECK_EXCLUDE_FALSE ;
661650 }
662651 }
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+ }
663662 }
664663
665664 /*
@@ -807,8 +806,8 @@ dir_check_file(pgFile *file)
807806 */
808807static void
809808dir_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 )
812811{
813812 DIR * dir ;
814813 struct dirent * dent ;
@@ -874,7 +873,7 @@ dir_list_file_internal(parray *files, pgFile *parent, const char *parent_dir,
874873
875874 if (exclude )
876875 {
877- check_res = dir_check_file (file );
876+ check_res = dir_check_file (file , backup_logs );
878877 if (check_res == CHECK_FALSE )
879878 {
880879 /* Skip */
@@ -897,7 +896,7 @@ dir_list_file_internal(parray *files, pgFile *parent, const char *parent_dir,
897896 */
898897 if (S_ISDIR (file -> mode ))
899898 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 );
901900 }
902901
903902 if (errno && errno != ENOENT )
@@ -1288,7 +1287,7 @@ check_tablespace_mapping(pgBackup *backup, bool incremental, bool *tblspaces_are
12881287}
12891288
12901289void
1291- check_external_dir_mapping (pgBackup * backup )
1290+ check_external_dir_mapping (pgBackup * backup , bool incremental )
12921291{
12931292 TablespaceListCell * cell ;
12941293 parray * external_dirs_to_restore ;
@@ -1341,7 +1340,7 @@ check_external_dir_mapping(pgBackup *backup)
13411340 char * external_dir = (char * ) parray_get (external_dirs_to_restore ,
13421341 i );
13431342
1344- if (!dir_is_empty (external_dir , FIO_DB_HOST ))
1343+ if (!incremental && ! dir_is_empty (external_dir , FIO_DB_HOST ))
13451344 elog (ERROR , "External directory is not empty: \"%s\"" ,
13461345 external_dir );
13471346 }
0 commit comments