Skip to content

windows: implement st_birthtime restoration, fixes #8730#9341

Draft
trxvorr wants to merge 1 commit into
borgbackup:masterfrom
trxvorr:fix-8730-win-birthtime
Draft

windows: implement st_birthtime restoration, fixes #8730#9341
trxvorr wants to merge 1 commit into
borgbackup:masterfrom
trxvorr:fix-8730-win-birthtime

Conversation

@trxvorr

@trxvorr trxvorr commented Feb 15, 2026

Copy link
Copy Markdown
Contributor

This PR implements the restoration of file creation time (st_birthtime) on Windows, addressing Issue #8730.

Changes

  • Platform Support: Added set_birthtime in src/borg/platform/init.py using ctypes and SetFileTime to precisely set creation time on NTFS.
  • Archiver: Updated Archive.restore_attrs to call set_birthtime on Windows when birthtime metadata is present.
  • Tests:
    • Added unit (win32_birthtime_test.py) and E2E (win32_birthtime_e2e_test.py) tests verifying birthtime preservation.
    • Updated is_birthtime_fully_supported and fixed test_nobirthtime to validly test birthtime behavior on Windows (handling st_birthtime != st_mtime semantics).

Verification

  • Verified on Windows with Python 3.12+.
  • New unit and E2E tests pass.
  • Existing test_nobirthtime now passes locally on Windows.

@trxvorr trxvorr force-pushed the fix-8730-win-birthtime branch from d6dbc75 to 2f50ad0 Compare February 15, 2026 15:50
@codecov

codecov Bot commented Feb 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.00000% with 12 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.45%. Comparing base (2357071) to head (e3edd5b).
⚠️ Report is 650 commits behind head on master.

Files with missing lines Patch % Lines
src/borg/platform/base.py 55.55% 7 Missing and 1 partial ⚠️
src/borg/platform/__init__.py 20.00% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9341      +/-   ##
==========================================
- Coverage   76.50%   76.45%   -0.06%     
==========================================
  Files          85       85              
  Lines       14818    14823       +5     
  Branches     2214     2214              
==========================================
- Hits        11337    11333       -4     
- Misses       2803     2813      +10     
+ Partials      678      677       -1     

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

Comment thread src/borg/platform/__init__.py Outdated
@trxvorr trxvorr force-pushed the fix-8730-win-birthtime branch 6 times, most recently from 9b57619 to a1face0 Compare February 15, 2026 19:59
Comment thread src/borg/testsuite/archiver/create_cmd_test.py Outdated
Comment thread src/borg/platform/base.py Outdated
@trxvorr trxvorr force-pushed the fix-8730-win-birthtime branch 4 times, most recently from 55000f7 to 91be6ae Compare February 15, 2026 20:58
Comment thread src/borg/platform/windows.pyx Outdated
Comment thread src/borg/testsuite/archiver/create_cmd_test.py Outdated
Comment thread src/borg/testsuite/archiver/extract_cmd_test.py Outdated
Comment thread src/borg/testsuite/archiver/extract_cmd_test.py Outdated
Comment thread src/borg/testsuite/archiver/win32_birthtime_e2e_test.py Outdated
Comment thread src/borg/testsuite/archiver/win32_birthtime_test.py Outdated
Comment thread src/borg/testsuite/__init__.py Outdated
Comment thread src/borg/testsuite/__init__.py Outdated
@trxvorr trxvorr marked this pull request as draft February 22, 2026 13:13
@ThomasWaldmann

Copy link
Copy Markdown
Member

Please update your local master branch and then rebase this branch onto that master and force push.

That should solve the CI test failures that are unrelated to your work.

@trxvorr trxvorr marked this pull request as ready for review February 25, 2026 15:32
@trxvorr trxvorr marked this pull request as draft February 25, 2026 15:33
@trxvorr trxvorr force-pushed the fix-8730-win-birthtime branch 3 times, most recently from bccac20 to ac834f1 Compare February 25, 2026 15:40
@trxvorr trxvorr force-pushed the fix-8730-win-birthtime branch 7 times, most recently from 9dac1c1 to 92d9236 Compare March 1, 2026 07:44
@trxvorr trxvorr marked this pull request as ready for review March 1, 2026 10:57
@trxvorr trxvorr requested a review from ThomasWaldmann March 1, 2026 10:57
@trxvorr trxvorr force-pushed the fix-8730-win-birthtime branch 2 times, most recently from af89193 to b54336a Compare March 1, 2026 11:07

@ThomasWaldmann ThomasWaldmann left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some feedback

Comment thread src/borg/platform/windows.pyx Outdated
Comment thread src/borg/platform/windows.pyx Outdated
Comment thread src/borg/platform/windows.pyx Outdated
Comment thread src/borg/testsuite/archiver/create_cmd_test.py Outdated
Comment thread src/borg/testsuite/archiver/create_cmd_test.py Outdated
Comment thread src/borg/testsuite/archiver/extract_cmd_test.py Outdated
Comment thread src/borg/testsuite/archiver/extract_cmd_test.py Outdated
Comment thread src/borg/testsuite/archiver/extract_cmd_test.py Outdated
Comment thread src/borg/testsuite/__init__.py Outdated
Comment thread src/borg/testsuite/__init__.py Outdated
@trxvorr trxvorr force-pushed the fix-8730-win-birthtime branch 6 times, most recently from ac40448 to bb3cb35 Compare March 1, 2026 19:14
@trxvorr trxvorr requested a review from ThomasWaldmann March 1, 2026 19:15
@ThomasWaldmann

Copy link
Copy Markdown
Member

Check the CI, there are quite some failures.

@trxvorr trxvorr force-pushed the fix-8730-win-birthtime branch from bb3cb35 to f9d6f05 Compare March 1, 2026 21:52
@trxvorr trxvorr force-pushed the fix-8730-win-birthtime branch from f9d6f05 to e3edd5b Compare March 2, 2026 00:40
@ThomasWaldmann

Copy link
Copy Markdown
Member

@trxvorr Before I review, please:

  • rebase on current master branch and fix the conflicts
  • try to fix the CI failures

@ThomasWaldmann

Copy link
Copy Markdown
Member

Same here, please rebase on current master, fix the conflicts, try to fix the CI failures.

@trxvorr trxvorr marked this pull request as draft March 14, 2026 14:55
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.

2 participants