Skip to content

Fixes #9495 preserve cwd archive metadata#9501

Open
ebuzerdrmz44 wants to merge 1 commit intoborgbackup:masterfrom
ebuzerdrmz44:fix/transfer-cwd-metadata
Open

Fixes #9495 preserve cwd archive metadata#9501
ebuzerdrmz44 wants to merge 1 commit intoborgbackup:masterfrom
ebuzerdrmz44:fix/transfer-cwd-metadata

Conversation

@ebuzerdrmz44
Copy link

Description

borg transfer was not preserving the cwdarchive metadata from the source archive. Instead, the transferred archive would end up with the cwd of the machine running the transfer command.

This adds cwd to the kept attributes in both UpgraderNoOp and UpgraderFrom12To20, so the original value is carried over. Also added a check for it test_transfer_archive_metadata.

Fixes #9495

Checklist

  • PR is against master (or maintenance branch if only applicable there)
  • New code has tests and docs where appropriate
  • Tests pass (run tox or the relevant test subset)
  • Commit messages are clean and reference related issues

@ThomasWaldmann ThomasWaldmann changed the title Fixes #9495 preserve cwd archieve metadata Fixes #9495 preserve cwd archive metadata Mar 17, 2026
for attr in ("hostname", "username", "comment", "chunker_params"):
for attr in ("hostname", "username", "comment", "chunker_params", "cwd"):
if hasattr(metadata, attr):
new_metadata[attr] = getattr(metadata, attr)
Copy link
Member

Choose a reason for hiding this comment

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

ok, guess that solves it for borg 1.4 archives that do have the cwd metadata (borg 1.4.4+).

but what happens if an older archive gets transferred that does not have the cwd metadata, what will be and what should be in the resulting archive?

Copy link
Author

Choose a reason for hiding this comment

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

thanks for the review. I guess we shouldn't check cwd inside the for loop. After the loop, could we check it specifically, like getattr(metadata, "cwd", "")?

Copy link
Author

Choose a reason for hiding this comment

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

But I'm not sure if "" is the best choice here . would you prefer leaving cwd unset or is that fine

Copy link
Member

Choose a reason for hiding this comment

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

if we can't know, having it unset might be the best choice. check if the code can cope with that.

@codecov
Copy link

codecov bot commented Mar 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 83.37%. Comparing base (1356aeb) to head (6a31587).
⚠️ Report is 7 commits behind head on master.
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #9501      +/-   ##
==========================================
+ Coverage   83.36%   83.37%   +0.01%     
==========================================
  Files          87       87              
  Lines       15439    15444       +5     
  Branches     2309     2310       +1     
==========================================
+ Hits        12870    12877       +7     
  Misses       1818     1818              
+ Partials      751      749       -2     

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

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.

borg2: transfer "cwd" archive metadata

2 participants