diff --git a/src/backup.c b/src/backup.c index 3b25c0d7..eb814034 100644 --- a/src/backup.c +++ b/src/backup.c @@ -1968,7 +1968,6 @@ parse_backup_filelist_filenames(parray *files, const char *root) int sscanf_result; relative = GetRelativePath(file->path, root); - file->is_cfs = false; filename[0] = '\0'; elog(VERBOSE, "-----------------------------------------------------: %s", relative); @@ -2042,7 +2041,7 @@ parse_backup_filelist_filenames(parray *files, const char *root) /* Found file in pg_tblspc/tblsOid/TABLESPACE_VERSION_DIRECTORY Legal only in case of 'pg_compression' */ - if (strcmp(relative + strlen(relative) - strlen("pg_compression"), "pg_compression") == 0) + if (strcmp(file->name, "pg_compression") == 0) { elog(VERBOSE, "Found pg_compression file in TABLESPACE_VERSION_DIRECTORY, filepath %s", relative); /*Set every datafile in tablespace as is_cfs */ @@ -2186,29 +2185,39 @@ set_cfs_datafiles(parray *files, const char *root, char *relative, size_t i) { int len; size_t p; + pgFile *prev_file; char *cfs_tblspc_path; + char *relative_prev_file; cfs_tblspc_path = strdup(relative); len = strlen("/pg_compression"); cfs_tblspc_path[strlen(cfs_tblspc_path) - len] = 0; elog(VERBOSE, "CFS DIRECTORY %s, pg_compression path: %s", cfs_tblspc_path, relative); - for (p = i; p != 0; p--) + for (p = i; p >= 0; p--) { - char *relative_prev_file; - pgFile *prev_file = (pgFile *) parray_get(files, p); + prev_file = (pgFile *) parray_get(files, p); relative_prev_file = GetRelativePath(prev_file->path, root); - //elog(VERBOSE, "P: %d, CHECKING file %s", p, relative_prev_file); + + //elog(VERBOSE, "P: %lu, Checking file in cfs tablespace %s", p, relative_prev_file); + elog(VERBOSE, "Checking file in cfs tablespace %s", relative_prev_file); + if (strstr(relative_prev_file, cfs_tblspc_path) != NULL) { if (S_ISREG(prev_file->mode) && prev_file->is_datafile) { - elog(VERBOSE, "Setting as 'is_cfs' file %s, fork %s", - relative_prev_file, prev_file->forkName); + elog(VERBOSE, "Setting 'is_cfs' on file %s, name %s", + relative_prev_file, prev_file->name); prev_file->is_cfs = true; } } + else + { + elog(VERBOSE, "Breaking on %s", relative_prev_file); + break; + } } + free(cfs_tblspc_path); } diff --git a/src/data.c b/src/data.c index ee893808..13f12534 100644 --- a/src/data.c +++ b/src/data.c @@ -317,13 +317,10 @@ backup_data_file(const char *from_root, const char *to_root, file->path, strerror(errno)); } - if (!file->is_cfs) + if (file->size % BLCKSZ != 0) { - if (file->size % BLCKSZ != 0) - { - fclose(in); - elog(ERROR, "File: %s, invalid file size %lu", file->path, file->size); - } + fclose(in); + elog(ERROR, "File: %s, invalid file size %lu", file->path, file->size); } /* diff --git a/src/dir.c b/src/dir.c index cb2b93fa..d2afd8d0 100644 --- a/src/dir.c +++ b/src/dir.c @@ -393,15 +393,20 @@ dir_list_file_internal(parray *files, const char *root, bool exclude, if (file_name == NULL) file_name = file->path; else + { file_name++; + file->name = file_name; + } /* Check if we need to exclude file by name */ for (i = 0; pgdata_exclude_files[i]; i++) - if (strcmp(file_name, pgdata_exclude_files[i]) == 0) + if (strcmp(file->name, pgdata_exclude_files[i]) == 0) + { /* Skip */ + elog(VERBOSE, "Excluding file: %s", file->name); return; + } } - parray_append(files, file); } @@ -463,7 +468,10 @@ dir_list_file_internal(parray *files, const char *root, bool exclude, if (dirname == NULL) dirname = file->path; else + { dirname++; + file->name = dirname; + } /* * If the item in the exclude list starts with '/', compare to the @@ -472,6 +480,7 @@ dir_list_file_internal(parray *files, const char *root, bool exclude, */ for (i = 0; exclude && pgdata_exclude_dir[i]; i++) { + /* Full-path exclude*/ if (pgdata_exclude_dir[i][0] == '/') { if (strcmp(file->path, pgdata_exclude_dir[i]) == 0) @@ -480,14 +489,17 @@ dir_list_file_internal(parray *files, const char *root, bool exclude, break; } } - else if (strcmp(dirname, pgdata_exclude_dir[i]) == 0) + else if (strcmp(file->name, pgdata_exclude_dir[i]) == 0) { skip = true; break; } } if (skip) + { + elog(VERBOSE, "Excluding directory content: %s", file->name); break; + } } /* open directory and list contents */ diff --git a/src/pg_probackup.h b/src/pg_probackup.h index b5771bec..8b8ca3e3 100644 --- a/src/pg_probackup.h +++ b/src/pg_probackup.h @@ -80,6 +80,7 @@ typedef enum CompressAlg /* Information about single file (or dir) in backup */ typedef struct pgFile { + char *name; /* file or directory name */ mode_t mode; /* protection (file type and permission) */ size_t size; /* size of the file */ size_t read_size; /* size of the portion read (if only some pages are @@ -90,7 +91,7 @@ typedef struct pgFile pg_crc32 crc; /* CRC value of the file, regular file only */ char *linked; /* path of the linked file */ bool is_datafile; /* true if the file is PostgreSQL data file */ - char *path; /* path of the file */ + char *path; /* absolute path of the file */ Oid tblspcOid; /* tblspcOid extracted from path, if applicable */ Oid dbOid; /* dbOid extracted from path, if applicable */ Oid relOid; /* relOid extracted from path, if applicable */