@@ -1207,14 +1207,63 @@ backup_files(void *arg)
1207
1207
}
1208
1208
1209
1209
/* copy the file into backup */
1210
- if (!(file -> is_datafile
1211
- ? backup_data_file (arguments -> from_root , arguments -> to_root , file , arguments -> lsn )
1212
- : copy_file (arguments -> from_root , arguments -> to_root , file )))
1210
+ if (file -> is_datafile )
1213
1211
{
1214
- /* record as skipped file in file_xxx.txt */
1215
- file -> write_size = BYTES_INVALID ;
1216
- elog (LOG , "skip" );
1217
- continue ;
1212
+ if (!backup_data_file (arguments -> from_root ,
1213
+ arguments -> to_root , file ,
1214
+ arguments -> lsn ))
1215
+ {
1216
+ /* record as skipped file in file_xxx.txt */
1217
+ file -> write_size = BYTES_INVALID ;
1218
+ elog (LOG , "skip" );
1219
+ continue ;
1220
+ }
1221
+ }
1222
+ else
1223
+ {
1224
+ /* Check if the file is a cfs relation's segment */
1225
+ bool is_cfs_relation_segment = false;
1226
+ pgFile tmp_file ;
1227
+ pgFile * * pre_search_file ;
1228
+ tmp_file .path = psprintf ("%s.cfm" , file -> path );
1229
+ pre_search_file = (pgFile * * ) parray_bsearch (arguments -> files , & tmp_file , pgFileComparePath );
1230
+ if (pre_search_file != NULL )
1231
+ {
1232
+ is_cfs_relation_segment = true;
1233
+ /* TODO If we don't have ptrack simply copy the file */
1234
+ if (file -> pagemap .bitmapsize == 0 )
1235
+ {
1236
+ is_cfs_relation_segment = false;
1237
+ elog (NOTICE , "1 file '%s' is a cfs relation's segment, bitmapsize == 0 \n" , file -> path );
1238
+ }
1239
+ }
1240
+ pg_free (tmp_file .path );
1241
+
1242
+
1243
+ if (is_cfs_relation_segment )
1244
+ {
1245
+ /*
1246
+ * TODO backup cfs segment
1247
+ * see backup_data_file()
1248
+ */
1249
+ elog (NOTICE , "2 file '%s' is a cfs relation's segment \n" , file -> path );
1250
+ elog (NOTICE , "2 file->pagemap.bitmapsize = %d" , file -> pagemap .bitmapsize );
1251
+ datapagemap_iterator_t * iter ;
1252
+ BlockNumber blknum = 0 ;
1253
+
1254
+ iter = datapagemap_iterate (& file -> pagemap );
1255
+ while (datapagemap_next (iter , & blknum ))
1256
+ elog (NOTICE , "2 blknum %u" , blknum );
1257
+ }
1258
+ else if (!copy_file (arguments -> from_root ,
1259
+ arguments -> to_root ,
1260
+ file ))
1261
+ {
1262
+ /* record as skipped file in file_xxx.txt */
1263
+ file -> write_size = BYTES_INVALID ;
1264
+ elog (LOG , "skip" );
1265
+ continue ;
1266
+ }
1218
1267
}
1219
1268
1220
1269
elog (LOG , "copied %lu" , (unsigned long ) file -> write_size );
@@ -1314,7 +1363,10 @@ add_files(parray *files, const char *root, bool add_root, bool is_pgdata)
1314
1363
{
1315
1364
if (current .backup_mode == BACKUP_MODE_DIFF_PTRACK ||
1316
1365
current .backup_mode == BACKUP_MODE_DIFF_PAGE )
1317
- elog (ERROR , "You can't use incremental backup with compress tablespace" );
1366
+ {
1367
+ elog (NOTICE , "You can't use incremental backup with compress tablespace" );
1368
+ /* TODO Add here incremental backup for compressed tablespaces */
1369
+ }
1318
1370
continue ;
1319
1371
}
1320
1372
@@ -1351,6 +1403,9 @@ add_files(parray *files, const char *root, bool add_root, bool is_pgdata)
1351
1403
}
1352
1404
1353
1405
/* mark cfs relations as not data */
1406
+ /* TODO
1407
+ * Don't mark cfs relations as not_datafile?
1408
+ * We can use similar code to check if the file is compressed */
1354
1409
for (i = 0 ; i < (int ) parray_num (list_file ); i ++ )
1355
1410
{
1356
1411
pgFile * file = (pgFile * ) parray_get (list_file , i );
0 commit comments