Skip to content

Comments

create: implement "file changed while backup" detection on Windows, fixes #9382#9384

Open
mr-raj12 wants to merge 1 commit intoborgbackup:masterfrom
mr-raj12:fix-win32-files-changed
Open

create: implement "file changed while backup" detection on Windows, fixes #9382#9384
mr-raj12 wants to merge 1 commit intoborgbackup:masterfrom
mr-raj12:fix-win32-files-changed

Conversation

@mr-raj12
Copy link
Contributor

Summary

  • The "file changed while being backed up" detection (fstat2 check) was entirely skipped on Windows via if not is_win32: # TODO for win32 since b3751b1 (March 2019, should print a warning if file changed during backup #1750)
  • On Windows, st_ctime is file creation time (not inode change time), so the default ctime-based detection was meaningless - but the mtime comparison path (added in b27df15, July 2025) works correctly on Windows since st_mtime updates
    on writes
  • Fix: remove the is_win32 guard so the fstat2 + comparison logic runs on all platforms, and default --files-changed to mtime on Windows instead of ctime
  • If a user explicitly passes --files-changed=ctime on Windows, borg now warns and falls back to mtime instead of silently disabling detection

Fixes #9382

Changes

File Change
src/borg/archive.py Remove if not is_win32 guard at fstat2 check; default files_changed to "mtime" on win32
src/borg/archiver/create_cmd.py Platform-aware argparse default; warn + fallback on --files-changed=ctime on Windows; update help text and docs
src/borg/testsuite/archiver/create_cmd_test.py Add test_files_changed_mtime — runs on all platforms including Windows

Related issues: #1750, #7193, #8730

Checklist

  • PR is against master
  • New code has tests
  • Commit message references related issue
  • Code formatted with black

@codecov
Copy link

codecov bot commented Feb 20, 2026

Codecov Report

❌ Patch coverage is 29.41176% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.43%. Comparing base (cace06f) to head (4f2480c).
⚠️ Report is 3 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/borg/archive.py 35.71% 4 Missing and 5 partials ⚠️
src/borg/archiver/create_cmd.py 0.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9384      +/-   ##
==========================================
- Coverage   76.44%   76.43%   -0.01%     
==========================================
  Files          85       85              
  Lines       14799    14802       +3     
  Branches     2212     2212              
==========================================
+ Hits        11313    11314       +1     
- Misses       2808     2809       +1     
- Partials      678      679       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mr-raj12 mr-raj12 force-pushed the fix-win32-files-changed branch from d5d96b3 to fb2a476 Compare February 20, 2026 17:24
@ThomasWaldmann
Copy link
Member

is_win32 is true for native windows (msys2/mingw).

what is the situation for cygwin (is_cygwin)?

@mr-raj12
Copy link
Contributor Author

Cygwin has is_win32 = False, so none of these changes affect it and it was already running the fstat2 check with ctime before, and still does. Cygwin maps st_ctime to NTFS ChangeTime (POSIX semantics), not CreationTime, so ctime works fine there.

@mr-raj12 mr-raj12 force-pushed the fix-win32-files-changed branch from fb2a476 to 4f2480c Compare February 20, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create: "file changed while backup" detection skipped on Windows (fstat2 TODO)

2 participants