Skip to content

Skip unchanged files #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 22 additions & 14 deletions src/backup.c
Original file line number Diff line number Diff line change
Expand Up @@ -2091,12 +2091,13 @@ backup_files(void *arg)

if (S_ISREG(buf.st_mode))
{
pgFile **prev_file;

/* Check that file exist in previous backup */
if (current.backup_mode != BACKUP_MODE_FULL)
{
char *relative;
pgFile key;
pgFile **prev_file;

relative = GetRelativePath(file->path, arguments->from_root);
key.path = relative;
Expand Down Expand Up @@ -2126,20 +2127,27 @@ backup_files(void *arg)
continue;
}
}
/* TODO:
* Check if file exists in previous backup
* If exists:
* if mtime > start_backup_time of parent backup,
* copy file to backup
* if mtime < start_backup_time
* calculate crc, compare crc to old file
* if crc is the same -> skip file
*/
else if (!copy_file(arguments->from_root, arguments->to_root, file))
else
{
file->write_size = BYTES_INVALID;
elog(VERBOSE, "File \"%s\" was not copied to backup", file->path);
continue;
bool skip = false;

/* If non-data file has not changed since last backup... */
if (file->exists_in_prev &&
buf.st_mtime < current.parent_backup)
{
calc_file_checksum(file);
/* ...and checksum is the same... */
if (EQ_CRC32C(file->crc, (*prev_file)->crc))
skip = true; /* ...skip copying file. */
}
if (skip ||
!copy_file(arguments->from_root, arguments->to_root, file))
{
file->write_size = BYTES_INVALID;
elog(VERBOSE, "File \"%s\" was not copied to backup",
file->path);
continue;
}
}

elog(VERBOSE, "File \"%s\". Copied "INT64_FORMAT " bytes",
Expand Down
2 changes: 1 addition & 1 deletion src/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ BlackListCompare(const void *str1, const void *str2)
* pgFile objects to "files". We add "root" to "files" if add_root is true.
*
* When omit_symlink is true, symbolic link is ignored and only file or
* directory llnked to will be listed.
* directory linked to will be listed.
*/
void
dir_list_file(parray *files, const char *root, bool exclude, bool omit_symlink,
Expand Down