@@ -867,8 +867,8 @@ do_backup(void)
867867 current .status = BACKUP_STATUS_DONE ;
868868 pgBackupWriteBackupControlFile (& current );
869869
870- elog (LOG , "Backup completed. Total bytes : " INT64_FORMAT "" ,
871- current .data_bytes );
870+ // elog(LOG, "Backup completed. Total bytes : " INT64_FORMAT "",
871+ // current.data_bytes);
872872
873873 pgBackupValidate (& current );
874874
@@ -910,7 +910,8 @@ check_server_version(void)
910910 server_version % 100 , "9.6" );
911911
912912 /* Do exclusive backup only for PostgreSQL 9.5 */
913- exclusive_backup = server_version < 90600 ;
913+ exclusive_backup = server_version < 90600 ||
914+ current .backup_mode == BACKUP_MODE_DIFF_PTRACK ;
914915
915916 /* Save server_version to use it in future */
916917 res = pgut_execute (backup_conn , "show server_version" , 0 , NULL );
@@ -1401,13 +1402,19 @@ wait_wal_lsn(XLogRecPtr lsn, bool wait_prev_segment)
14011402 timeout = archive_timeout ;
14021403 }
14031404
1405+ if (wait_prev_segment )
1406+ elog (LOG , "Looking for segment: %s" , wal_segment );
1407+ else
1408+ elog (LOG , "Looking for LSN: %X/%X in segment: %s" , (uint32 ) (lsn >> 32 ), (uint32 ) lsn , wal_segment );
1409+
14041410 /* Wait until target LSN is archived or streamed */
14051411 while (true)
14061412 {
14071413 bool file_exists = fileExists (wal_segment_full_path );
14081414
14091415 if (file_exists )
14101416 {
1417+ elog (LOG , "Found segment: %s" , wal_segment );
14111418 /* Do not check LSN for previous WAL segment */
14121419 if (wait_prev_segment )
14131420 return ;
@@ -1418,7 +1425,10 @@ wait_wal_lsn(XLogRecPtr lsn, bool wait_prev_segment)
14181425 if ((stream_wal && wal_contains_lsn (wal_dir , lsn , tli )) ||
14191426 (!stream_wal && wal_contains_lsn (arclog_path , lsn , tli )))
14201427 /* Target LSN was found */
1428+ {
1429+ elog (LOG , "Found LSN: %X/%X" , (uint32 ) (lsn >> 32 ), (uint32 ) lsn );
14211430 return ;
1431+ }
14221432 }
14231433
14241434 sleep (1 );
@@ -1653,6 +1663,8 @@ pg_stop_backup(pgBackup *backup)
16531663 }
16541664 if (!res )
16551665 elog (ERROR , "pg_stop backup() failed" );
1666+ else
1667+ elog (INFO , "pg_stop backup() successfully executed" );
16561668 }
16571669
16581670 backup_in_progress = false;
@@ -1990,13 +2002,15 @@ backup_files(void *arg)
19902002/*
19912003 * Extract information about files in backup_list parsing their names:
19922004 * - remove temp tables from the list
2005+ * - remove unlogged tables from the list (leave the _init fork)
19932006 * - set flags for database directories
19942007 * - set flags for datafiles
19952008 */
19962009static void
19972010parse_backup_filelist_filenames (parray * files , const char * root )
19982011{
19992012 size_t i ;
2013+ Oid unlogged_file_reloid = 0 ;
20002014
20012015 for (i = 0 ; i < parray_num (files ); i ++ )
20022016 {
@@ -2157,13 +2171,46 @@ parse_backup_filelist_filenames(parray *files, const char *root)
21572171 /* auxiliary fork of the relfile */
21582172 sscanf (filename , "%u_%s" , & (file -> relOid ), file -> forkName );
21592173 elog (VERBOSE , "relOid %u, forkName %s, filepath %s" , file -> relOid , file -> forkName , relative );
2160- if (strcmp (file -> forkName , "ptrack" ) == 0 )
2174+
2175+ /* handle unlogged relations */
2176+ if (strcmp (file -> forkName , "init" ) == 0 )
2177+ {
2178+ /*
2179+ * Do not backup files of unlogged relations.
2180+ * scan filelist backward and exclude these files.
2181+ */
2182+ int unlogged_file_num = i - 1 ;
2183+ pgFile * unlogged_file = (pgFile * ) parray_get (files , unlogged_file_num );
2184+
2185+ unlogged_file_reloid = file -> relOid ;
2186+
2187+ while (unlogged_file_num >= 0 &&
2188+ (unlogged_file_reloid != 0 ) &&
2189+ (unlogged_file -> relOid == unlogged_file_reloid ))
2190+ {
2191+ unlogged_file -> size = 0 ;
2192+ pgFileFree (unlogged_file );
2193+ parray_remove (files , unlogged_file_num );
2194+ unlogged_file_num -- ;
2195+ i -- ;
2196+ unlogged_file = (pgFile * ) parray_get (files , unlogged_file_num );
2197+ }
2198+ }
2199+ else if (strcmp (file -> forkName , "ptrack" ) == 0 )
21612200 {
21622201 /* Do not backup ptrack files */
21632202 pgFileFree (file );
21642203 parray_remove (files , i );
21652204 i -- ;
21662205 }
2206+ else if ((unlogged_file_reloid != 0 ) &&
2207+ (file -> relOid == unlogged_file_reloid ))
2208+ {
2209+ /* Do not backup forks of unlogged relations */
2210+ pgFileFree (file );
2211+ parray_remove (files , i );
2212+ i -- ;
2213+ }
21672214 continue ;
21682215 }
21692216
@@ -2201,6 +2248,15 @@ parse_backup_filelist_filenames(parray *files, const char *root)
22012248 */
22022249 elog (VERBOSE , "relOid %u, segno %d, suffix %s, filepath %s" , file -> relOid , file -> segno , suffix , relative );
22032250 }
2251+
2252+ if ((unlogged_file_reloid != 0 ) &&
2253+ (file -> relOid == unlogged_file_reloid ))
2254+ {
2255+ /* Do not backup segments of unlogged files */
2256+ pgFileFree (file );
2257+ parray_remove (files , i );
2258+ i -- ;
2259+ }
22042260 }
22052261 }
22062262 }
0 commit comments