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

fix: for Windows, copy snapshot files being backed up #22551

Merged
merged 1 commit into from Sep 22, 2021

Conversation

davidby-influx
Copy link
Contributor

On Windows, make copies of files for snapshots, because
Go does not support the FILE_SHARE_DELETE flag which
allows files (and links) to be deleted while open. This
causes temporary directories to be left behind after
backups.

closes #16289

On Windows, make copies of files for snapshots, because
Go does not support the FILE_SHARE_DELETE flag which
allows files (and links) to be deleted while open. This
causes temporary directories to be left behind after
backups.

closes #16289
@lesam
Copy link
Contributor

lesam commented Sep 22, 2021

This should get backported to 1.8

)

// copyOrLink - allow substitution of a file copy for a hard link when running on Windows systems.
func copyOrLink(oldPath, newPath string) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be more straightforward to just check runtime.GOOS == "windows", but this is fine

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That was my original implementation, but reading various Go blogs convinced me conditional compilation was more idiomatic.

if _, err := io.Copy(wfd, rfd); err != nil {
return fmt.Errorf("unable to copy file for backup from %s to %s: %q", oldPath, newPath, err)
}
if err := os.Chtimes(newPath, fi.ModTime(), fi.ModTime()); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Kind of ugly that Chtimes takes aTime here but only exposes reading ModTime in a cross-platform way - might be worth a comment

@davidby-influx davidby-influx merged commit 3702fe8 into master-1.x Sep 22, 2021
@davidby-influx davidby-influx deleted the DSB_windows_temp branch September 22, 2021 18:03
davidby-influx added a commit that referenced this pull request Sep 22, 2021
On Windows, make copies of files for snapshots, because
Go does not support the FILE_SHARE_DELETE flag which
allows files (and links) to be deleted while open. This
causes temporary directories to be left behind after
backups.

closes #16289

(cherry picked from commit 3702fe8)
davidby-influx added a commit that referenced this pull request Sep 22, 2021
On Windows, make copies of files for snapshots, because
Go does not support the FILE_SHARE_DELETE flag which
allows files (and links) to be deleted while open. This
causes temporary directories to be left behind after
backups.

closes #16289

(cherry picked from commit 3702fe8)

closes #22557
davidby-influx added a commit that referenced this pull request Sep 22, 2021
On Windows, make copies of files for snapshots, because
Go does not support the FILE_SHARE_DELETE flag which
allows files (and links) to be deleted while open. This
causes temporary directories to be left behind after
backups.

closes #16289

(cherry picked from commit 3702fe8)

closes #22557
davidby-influx added a commit that referenced this pull request Sep 22, 2021
On Windows, make copies of files for snapshots, because
Go does not support the FILE_SHARE_DELETE flag which
allows files (and links) to be deleted while open. This
causes temporary directories to be left behind after
backups.

closes #16289

(cherry picked from commit 3702fe8)

closes #22557

(cherry picked from commit 47007f6)
davidby-influx added a commit that referenced this pull request Sep 22, 2021
… (#22563)

On Windows, make copies of files for snapshots, because
Go does not support the FILE_SHARE_DELETE flag which
allows files (and links) to be deleted while open. This
causes temporary directories to be left behind after
backups.

closes #16289

(cherry picked from commit 3702fe8)

closes #22557

(cherry picked from commit 47007f6)

closes #22558
davidby-influx added a commit that referenced this pull request Oct 14, 2021
On Windows, make copies of files for snapshots, because
Go does not support the FILE_SHARE_DELETE flag which
allows files (and links) to be deleted while open. This
causes temporary directories to be left behind after
backups.

closes #16289

(cherry picked from commit 3702fe8)
davidby-influx added a commit that referenced this pull request Oct 14, 2021
On Windows, make copies of files for snapshots, because
Go does not support the FILE_SHARE_DELETE flag which
allows files (and links) to be deleted while open. This
causes temporary directories to be left behind after
backups.

closes #16289

(cherry picked from commit 3702fe8)

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

Successfully merging this pull request may close these issues.

Running influxd.exe backup -portable leaves <x>.tmp folders in data directory on Windows
2 participants