Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove existing path before restoring a symlink #3780

Merged
merged 3 commits into from Sep 24, 2022

Conversation

jkmw
Copy link
Contributor

@jkmw jkmw commented Jun 1, 2022

Bugfix: Make sure that symlinks can be created during recovery

When restoring a symlink, restic reported an error if the target path already existed.
With this change, the potentially existing target path is first removed before the symlink is recreated.

#2578

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

At the moment restic overwrites existing data in the restore target, unless it is a symlink, in which case an error is thrown.

From my point of view, restic should behave with symlinks in the same way as with all other file types and "overwrite" already existing paths.

This change causes restic to "overwrite" existing data (by delete and create) even if a symlink is to be restored.

See #2578 for more details.

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

Closes #2578

Checklist

@MichaelEischer
Copy link
Member

Also please add a short changelog entry using the template at https://github.com/restic/restic/blob/master/changelog/TEMPLATE

@MichaelEischer
Copy link
Member

I guess I haven't been explicitly enough in my previous comment: replacing os.RemoveAll with os.Remove was not a suggestion, but rather a request. The other parts of the restorer do not wipe out entire directory trees if these are standing in the way, thus restoring a symlink must behave just the same.

Copy link
Member

@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. Thanks!

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.

Restore of a existing symlink(with same content) fails
2 participants