@@ -1990,13 +1990,15 @@ backup_files(void *arg)
1990
1990
/*
1991
1991
* Extract information about files in backup_list parsing their names:
1992
1992
* - remove temp tables from the list
1993
+ * - remove unlogged tables from the list (leave the _init fork)
1993
1994
* - set flags for database directories
1994
1995
* - set flags for datafiles
1995
1996
*/
1996
1997
static void
1997
1998
parse_backup_filelist_filenames (parray * files , const char * root )
1998
1999
{
1999
2000
size_t i ;
2001
+ Oid unlogged_file_reloid = 0 ;
2000
2002
2001
2003
for (i = 0 ; i < parray_num (files ); i ++ )
2002
2004
{
@@ -2157,13 +2159,46 @@ parse_backup_filelist_filenames(parray *files, const char *root)
2157
2159
/* auxiliary fork of the relfile */
2158
2160
sscanf (filename , "%u_%s" , & (file -> relOid ), file -> forkName );
2159
2161
elog (VERBOSE , "relOid %u, forkName %s, filepath %s" , file -> relOid , file -> forkName , relative );
2160
- if (strcmp (file -> forkName , "ptrack" ) == 0 )
2162
+
2163
+ /* handle unlogged relations */
2164
+ if (strcmp (file -> forkName , "init" ) == 0 )
2165
+ {
2166
+ /*
2167
+ * Do not backup files of unlogged relations.
2168
+ * scan filelist backward and exclude these files.
2169
+ */
2170
+ int unlogged_file_num = i - 1 ;
2171
+ pgFile * unlogged_file = (pgFile * ) parray_get (files , unlogged_file_num );
2172
+
2173
+ unlogged_file_reloid = file -> relOid ;
2174
+
2175
+ while (unlogged_file_num >= 0 &&
2176
+ (unlogged_file_reloid != 0 ) &&
2177
+ (unlogged_file -> relOid == unlogged_file_reloid ))
2178
+ {
2179
+ unlogged_file -> size = 0 ;
2180
+ pgFileFree (unlogged_file );
2181
+ parray_remove (files , unlogged_file_num );
2182
+ unlogged_file_num -- ;
2183
+ i -- ;
2184
+ unlogged_file = (pgFile * ) parray_get (files , unlogged_file_num );
2185
+ }
2186
+ }
2187
+ else if (strcmp (file -> forkName , "ptrack" ) == 0 )
2161
2188
{
2162
2189
/* Do not backup ptrack files */
2163
2190
pgFileFree (file );
2164
2191
parray_remove (files , i );
2165
2192
i -- ;
2166
2193
}
2194
+ else if ((unlogged_file_reloid != 0 ) &&
2195
+ (file -> relOid == unlogged_file_reloid ))
2196
+ {
2197
+ /* Do not backup forks of unlogged relations */
2198
+ pgFileFree (file );
2199
+ parray_remove (files , i );
2200
+ i -- ;
2201
+ }
2167
2202
continue ;
2168
2203
}
2169
2204
@@ -2201,6 +2236,15 @@ parse_backup_filelist_filenames(parray *files, const char *root)
2201
2236
*/
2202
2237
elog (VERBOSE , "relOid %u, segno %d, suffix %s, filepath %s" , file -> relOid , file -> segno , suffix , relative );
2203
2238
}
2239
+
2240
+ if ((unlogged_file_reloid != 0 ) &&
2241
+ (file -> relOid == unlogged_file_reloid ))
2242
+ {
2243
+ /* Do not backup segments of unlogged files */
2244
+ pgFileFree (file );
2245
+ parray_remove (files , i );
2246
+ i -- ;
2247
+ }
2204
2248
}
2205
2249
}
2206
2250
}
0 commit comments