Skip to content

backup: Fix --stdin-filename with directory#5356

Merged
MichaelEischer merged 9 commits intorestic:masterfrom
MichaelEischer:fix-backup-stdin-filename
Jun 2, 2025
Merged

backup: Fix --stdin-filename with directory#5356
MichaelEischer merged 9 commits intorestic:masterfrom
MichaelEischer:fix-backup-stdin-filename

Conversation

@MichaelEischer
Copy link
Copy Markdown
Member

What does this PR change? What problem does it solve?

In restic 0.18.0, the backup command failed if a filename that includes a least a directory was passed to --stdin-filename. For example, --stdin-filename /foo/bar resulted in the following error:

Fatal: unable to save snapshot: open /foo: no such file or directory

With the FS interface changes included in restic 0.18.0, it is now necessary for the fs.Reader struct to handle intermediate directories correctly. This is now ensured by constructing the directory right when initializing the Reader. Thereby, the full path handling is only necessary once. The accessor functions then just can look up the relevant directory entry.

The intermediate directories now use the same timestamp as the file. This ensures that the snapshot content is fully deterministic when the timestamp is specified. I've also added proper error handling for that case that an invalid path was specified.

Was the change previously discussed in an issue or on the forum?

Fixes #5324

Checklist

  • I have added tests for all code changes.
  • [ ] I have added documentation for relevant changes (in the manual).
  • [x ] There's a new file in changelog/unreleased/ that describes the changes for our users (see template).
  • I'm done! This pull request is ready for review.

This adds proper support for filenames that include directories. For
example, `/foo/bar` would result in an error when trying to open `/foo`.

The directory tree is now build upfront. This ensures let's the
directory tree construction be handled only once. All accessors then
only have to look up the constructed directory entries.
This ensures that a fixed input generates a fully deterministic output
file structure.
Copy link
Copy Markdown
Member Author

@MichaelEischer MichaelEischer left a comment

Choose a reason for hiding this comment

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

LGTM.

@MichaelEischer MichaelEischer merged commit e4a7f4a into restic:master Jun 2, 2025
11 checks passed
@MichaelEischer MichaelEischer deleted the fix-backup-stdin-filename branch June 2, 2025 18:27
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.

--stdin-filename no longer accepts absolute path name

1 participant