Skip to content

Enhancement: Allow stripping path components during restore#5681

Open
Paulomen2712 wants to merge 1 commit into
restic:masterfrom
Paulomen2712:restore-skip-components
Open

Enhancement: Allow stripping path components during restore#5681
Paulomen2712 wants to merge 1 commit into
restic:masterfrom
Paulomen2712:restore-skip-components

Conversation

@Paulomen2712

@Paulomen2712 Paulomen2712 commented Jan 21, 2026

Copy link
Copy Markdown
Contributor

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

Added support for stripping leading path components when restoring
files and directories, similar to tar’s --strip-components option.

Previously, restic always restored the full original path under the target
directory. For example, restoring /home/work/foo to /home/restores
would result in /home/restores/home/work/foo.

With this change, users can specify --strip-components=N to skip the
first N directory levels during restore. Pathnames with fewer elements will be silently skipped.

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

Closes #5639

Checklist

  • I have added tests for all code changes.
  • I have added documentation for relevant changes (in the manual).
  • 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.

Restores previously always recreated the full original path under the
target directory. For example, restoring /home/work/foo to
/home/restores would result in /home/restores/home/work/foo.

This change adds support for stripping leading path components during
restore, similar to tar’s --strip-components option. Users can now
skip the first N directories when restoring, making it more convenient to place
files directly at the desired target location.
@Paulomen2712 Paulomen2712 force-pushed the restore-skip-components branch from 122cf9f to 79b2940 Compare January 21, 2026 15:09
@Paulomen2712 Paulomen2712 changed the title Allow stripping path components during restore Enhancement: Allow stripping path components during restore Feb 2, 2026
@Paulomen2712 Paulomen2712 mentioned this pull request Feb 20, 2026
2 tasks
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.

Introduce path mapping for backup and restore commands

2 participants