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

change backup to use os.Link #1265

Merged
merged 1 commit into from
Aug 30, 2019
Merged

change backup to use os.Link #1265

merged 1 commit into from
Aug 30, 2019

Conversation

eikenb
Copy link
Contributor

@eikenb eikenb commented Aug 22, 2019

Instead of opening a new file and manually copying over the contents,
just use a hard link. This has different tradeoffs vs manually copying
(eg. it isn't supported on plan9), but should generally be more robust
and has no race.

This also changes it to just log an error vs returning it, in the case
of a os.Link returning an error, as that causes consul-template to exit
(which we don't want for this).

Instead of opening a new file and manually copying over the contents,
just use a hard link. This has different tradeoffs vs manually copying
(eg. it isn't supported on plan9), but should generally be more robust
and has no race.

This also changes it to just log an error vs returning it, in the case
of a os.Link returning an error, as that causes consul-template to exit
(which we don't want for this).
@eikenb eikenb requested review from a team August 22, 2019 21:10
@eikenb eikenb added the bug label Aug 22, 2019
@eikenb eikenb added this to the 0.21.1 milestone Aug 22, 2019
Copy link
Member

@hanshasselberg hanshasselberg left a comment

Choose a reason for hiding this comment

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

👍

@eikenb eikenb merged commit 7e760ef into master Aug 30, 2019
@eikenb eikenb deleted the issue1264-backup-race branch August 30, 2019 20:07
@liuxu623
Copy link

liuxu623 commented Aug 31, 2019

There is a bug, if xxx.bak is already exist, os.Link will return file exists error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants