@@ -2096,12 +2096,13 @@ backup_files(void *arg)
20962096
20972097 if (S_ISREG (buf .st_mode ))
20982098 {
2099+ pgFile * * prev_file ;
2100+
20992101 /* Check that file exist in previous backup */
21002102 if (current .backup_mode != BACKUP_MODE_FULL )
21012103 {
21022104 char * relative ;
21032105 pgFile key ;
2104- pgFile * * prev_file ;
21052106
21062107 relative = GetRelativePath (file -> path , arguments -> from_root );
21072108 key .path = relative ;
@@ -2131,20 +2132,27 @@ backup_files(void *arg)
21312132 continue ;
21322133 }
21332134 }
2134- /* TODO:
2135- * Check if file exists in previous backup
2136- * If exists:
2137- * if mtime > start_backup_time of parent backup,
2138- * copy file to backup
2139- * if mtime < start_backup_time
2140- * calculate crc, compare crc to old file
2141- * if crc is the same -> skip file
2142- */
2143- else if (!copy_file (arguments -> from_root , arguments -> to_root , file ))
2135+ else
21442136 {
2145- file -> write_size = BYTES_INVALID ;
2146- elog (VERBOSE , "File \"%s\" was not copied to backup" , file -> path );
2147- continue ;
2137+ bool skip = false;
2138+
2139+ /* If non-data file has not changed since last backup... */
2140+ if (file -> exists_in_prev &&
2141+ buf .st_mtime < current .parent_backup )
2142+ {
2143+ calc_file_checksum (file );
2144+ /* ...and checksum is the same... */
2145+ if (EQ_CRC32C (file -> crc , (* prev_file )-> crc ))
2146+ skip = true; /* ...skip copying file. */
2147+ }
2148+ if (skip ||
2149+ !copy_file (arguments -> from_root , arguments -> to_root , file ))
2150+ {
2151+ file -> write_size = BYTES_INVALID ;
2152+ elog (VERBOSE , "File \"%s\" was not copied to backup" ,
2153+ file -> path );
2154+ continue ;
2155+ }
21482156 }
21492157
21502158 elog (VERBOSE , "File \"%s\". Copied " INT64_FORMAT " bytes" ,
0 commit comments