Skip to content

backup: fix possible crash if directory disappears before metadata collection#5421

Merged
MichaelEischer merged 6 commits intorestic:masterfrom
MichaelEischer:fix-backup-metadata-crash
Sep 5, 2025
Merged

backup: fix possible crash if directory disappears before metadata collection#5421
MichaelEischer merged 6 commits intorestic:masterfrom
MichaelEischer:fix-backup-metadata-crash

Conversation

@MichaelEischer
Copy link
Copy Markdown
Member

@MichaelEischer MichaelEischer commented Jun 12, 2025

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

Fix a crash during the backup in nodeFromFileInfo in two cases:

  • if a directory is deleted between restic stating it and trying to list its directory content.
  • when restic tries to list the parent directory of a backup target, but the parent directory has been deleted.

A backup also no longer completely fails if a parent folder becomes inaccessible during the backup. This only becomes relevant with the above crash fix as this scenario most likely results in a crash in restic 0.18.0.
The general idea is to also handle errors for parent directories of backup directories in the same way as all other file access errors during a backup.

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

Partially addresses #5391 .

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.

@MichaelEischer MichaelEischer force-pushed the fix-backup-metadata-crash branch from 4da5fb3 to 64df0b6 Compare July 21, 2025 19:51
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.

this could crash in two cases:
- if a directory is deleted between restic stating it and trying to list
  its directory content.
- when restic tries to list the parent directory of a backup target, but
  the parent directory has been deleted.

return an error in this case instead.
Handle errors for parent directories of backup directories in the same
way as all other file access errors during a backup.
@MichaelEischer MichaelEischer force-pushed the fix-backup-metadata-crash branch from 4957dad to 484b706 Compare September 5, 2025 17:28
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 again

@MichaelEischer MichaelEischer merged commit e98c44b into restic:master Sep 5, 2025
11 checks passed
@MichaelEischer MichaelEischer deleted the fix-backup-metadata-crash branch September 6, 2025 20:00
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.

1 participant