restic: self-update doesn't work on Windows
Output of restic version
restic 0.9.4 compiled with go1.11.4 on windows/amd64
How did you run restic exactly?
>>> restic self-update
writing restic to C:\<...>\restic\restic.exe
find latest release of restic at GitHub
latest version is 0.9.5
download SHA256SUMS
download SHA256SUMS.asc
GPG signature verification succeeded
download restic_0.9.5_windows_amd64.zip
downloaded restic_0.9.5_windows_amd64.zip
Fatal: unable to update restic: unable to remove target file: remove C:\<...>\restic\restic.exe: Access is denied.
What backend/server/service did you use to store the repository?
N/A
Expected behavior
Update the binary.
Actual behavior
restic unable to update itself.
Steps to reproduce the behavior
Run restic self-update on Windows.
Do you have any idea what may have caused this?
Windows doesn’t allow write access to a running executable.
Do you have an idea how to solve the issue?
Just an idea:
- Download the new binary
- Rename its old self to
<original-path/name>-old(or move to$TMP/<original-name>) - Move and rename the new binary to
<original-path/name> - Automatically launch the new binary then exit
- The new binary automatically cleans up the old version then exits
Did restic help you or made you happy in any way?
Absolutely. Having efficient, regular, and secure backups is awesome.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 7
- Comments: 16 (4 by maintainers)
Commits related to this issue
- Refactor file handing for self-update. * Write new file payload to a temp file before touching the original binary. Minimizes the possibility of failing mid-write and corrupting the binary. * Move th... — committed to ItsMattL/restic by ItsMattL 3 years ago
- Refactor file handing for self-update. * Write new file payload to a temp file before touching the original binary. Minimizes the possibility of failing mid-write and corrupting the binary. * Move th... — committed to ItsMattL/restic by ItsMattL 3 years ago
- Refactor file handing for self-update. * Write new file payload to a temp file before touching the original binary. Minimizes the possibility of failing mid-write and corrupting the binary. * Move th... — committed to ItsMattL/restic by ItsMattL 3 years ago
- Refactor file handing for self-update. * Write new file payload to a temp file before touching the original binary. Minimizes the possibility of failing mid-write and corrupting the binary. * Move th... — committed to ItsMattL/restic by ItsMattL 3 years ago
- Refactor file handing for self-update. * Write new file payload to a temp file before touching the original binary. Minimizes the possibility of failing mid-write and corrupting the binary. * Move th... — committed to ItsMattL/restic by ItsMattL 3 years ago
- Refactor file handing for self-update. * Write new file payload to a temp file before touching the original binary. Minimizes the possibility of failing mid-write and corrupting the binary. * Move th... — committed to ItsMattL/restic by ItsMattL 3 years ago
- Refactor file handing for self-update. * Write new file payload to a temp file before touching the original binary. Minimizes the possibility of failing mid-write and corrupting the binary. * Move th... — committed to ItsMattL/restic by ItsMattL 3 years ago
- Refactor file handing for self-update. * Write new file payload to a temp file before touching the original binary. Minimizes the possibility of failing mid-write and corrupting the binary. * Move th... — committed to ItsMattL/restic by ItsMattL 3 years ago
- Refactor file handing for self-update. * Write new file payload to a temp file before touching the original binary. Minimizes the possibility of failing mid-write and corrupting the binary. * Move th... — committed to ItsMattL/restic by ItsMattL 3 years ago
- Refactor file handing for self-update. * Write new file payload to a temp file before touching the original binary. Minimizes the possibility of failing mid-write and corrupting the binary. * Move th... — committed to ItsMattL/restic by ItsMattL 3 years ago
- Refactor file handing for self-update. * Write new file payload to a temp file before touching the original binary. Minimizes the possibility of failing mid-write and corrupting the binary. * Move th... — committed to ItsMattL/restic by ItsMattL 3 years ago
- Refactor file handing for self-update. * Write new file payload to a temp file before touching the original binary. Minimizes the possibility of failing mid-write and corrupting the binary. * On Wind... — committed to ItsMattL/restic by ItsMattL 3 years ago
- Refactor file handing for self-update. * Write new file payload to a temp file before touching the original binary. Minimizes the possibility of failing mid-write and corrupting the binary. * On Wind... — committed to ItsMattL/restic by ItsMattL 3 years ago
Let’s not be overdramatic. restic backs up data on Windows well. There may be a few more bugs and a few missing features, but nothing major that prevents you from using it effectively on Windows.
Also, please don’t sidetrack this issue’s discussion.
Ah, then rather use
restic self-update --output temp-restic.exe, that’ll at least verify the authenticity of the binary. You can then move it to the right location manually.The readme.md says “It supports the three major operating systems (Linux, macOS, Windows)”.
Could the claim that restic supports Windows please be removed until this and any other major issues with Windows support are fixed (or at least, put a big fat mention that it’s in Beta)?
I think that something like that should be the default on all operating systems.
Currently, if you run restic self-update on linux, and it gets interrupted while it is running, you end up with a truncated and useless restic binary. It would be much better if the replacement of the old binary with the new is done via some sort of atomic operation.
Moving the running binary before writing the updated version in place version will indeed fix the issue. The running binary remains locked while running, but it can rename itself to something else. Since we have so many options, I’d like to get some input from the restic maintainers (@fd0 ?) before I submit a patch.
Hi,
Can I suggest this library https://github.com/inconshreveable/go-update ? With go-update you can build self-updating Go programs and Windows is supported.