Restic 0.18.0 Released

We are happy to announce the release of restic 0.18.0!


This is a companion discussion topic for the original entry at https://restic.net/blog/2025-03-27/restic-0.18.0-released
8 Likes

Being a Windows 7 user, I cannot use pre-compiled Restic binaries, so I have to build it myself. I managed to do that, Restic works as expected, however I have a question related to binary size.

Official restic_0.18.0_windows_amd64.exe is 30 463 488 bytes.

$ go install github.com/restic/restic/cmd/restic@latest

produces restic.exe 59 909 120 bytes

$ go install -ldflags="-s -w" github.com/restic/restic/cmd/restic@latest

produces restic.exe 41 369 088 bytes.

As you can see, the difference between my best try and yours is about 10 MB. How did you manage to lose weight? Tell me the command, please.

restic released binaries are reproducible so you should be able to build exactly the same binary.

Here more details:

Where you also find “the command” you are after.

I need the exact command to build Restic for Windows using install command as Go team recommends, not a link to the documentation where I have not found such a command no matter how hard I tried. Please, be a human, not AI-version of human and give me the exact command.

$ go install [MAGICAL SWITCHES in addition to -ldflags="-s -w"]
     ^^^^^^^
     not get, not build, but install

I believe that the description restic/doc/developer_information.rst at master · restic/restic · GitHub states very clearly how to reproduce the build. I think this is the most central step:

$ GOOS=windows GOARCH=amd64 CGO_ENABLED=0 go build -ldflags "-s -w" -tags selfupdate -o restic_0.14.0_windows_amd64.exe ./cmd/restic

1 Like

Martin, we are talking about different things. You are pointing me to a page with official instructions on how to reproduce the official Restic build. But I do NOT want to reproduce what is available in the releases section on Github. I want to build Restic via modern install command that Go team recommends using today and get the smallest possible executable file, which is close to the official one. So far there is no mention of building Restic via install command in the official documentation. I’ve checked my message for errors several times, highlighted important pieces in capital letters and bold, I don’t know what else to add to make you understand me.

Now I am a bit puzzled. Is it just purely academic curiosity how to do something using some specific command even if other command produces exactly what your goal is - smaller executable?

Is your goal to build small exe? Or explore go install (which is not used by restic build process) capabilities?

Sir, there are TWO known ways to convert Go source code into EXE file.

The first way, say, traditional one, is described in the Restic official documentation. You download the source code with all dependencies from Github, unpack it to some folder on your computer and then execute go build command with some flags to build EXE file.

The second way, say, modern one, is to use go install command. It is not some kind of underground way to build Go apps, it is recommended by Go team (the link was given twice above). It is designed to save the user from all the additional steps of downloading and unpacking, it does it all by itself and you get EXE after it is finished.

I have used go install to build a lot of Go apps lately. For example, Age, Croc, Doggo, F2, Kopia, PDFcpu, etc. In their case, the size of the executable file is more or less the same as the size of the file that is posted on the Github. But in the case of Restic, for some unknown reason, the file turns out to be 10 MB larger. And I hope that there is someone here (the main developer, for example) who is privy to the details of Restic development to such an extent as to suggest why.

You should add -tags disable_grpc_modules switch to the install command.

2 Likes

Hallelujah, brother, it helped! Now I have restic.exe which is even slightly smaller than the official one. Thank you from the bottom of my heart!

Also I believe the official documentation should be updated as soon as possible, because it is no longer relevant. I followed it step by step using go build way and got the same large EXE (~40 MB) as go install produced earlier. But -tags disable_grpc_modules helped in both cases.

Build log (2025-03-30)
$ ver && go version
Microsoft Windows [Version 6.1.7601]
go version go1.23.6 windows/amd64
rem Contents of restic-go-build.cmd
mkdir restic
cd restic
curl -L https://github.com/restic/restic/releases/download/v0.18.0/restic-0.18.0.tar.gz | busybox tar xz --strip-components=1
set GOOS=windows
set GOARCH=amd64
set CGO_ENABLED=0
go build -ldflags "-s -w" -tags selfupdate -o restic_0.18.0_windows_amd64.exe ./cmd/restic
$ restic_0.18.0_windows_amd64.exe version
restic 0.18.0 compiled with go1.23.6 on windows/amd64

$ busybox du -h restic_0.18.0_windows_amd64.exe 
39.9M   restic_0.18.0_windows_amd64.exe

$ busybox du -h restic_0.18.0_windows_amd64_official.exe
29.1M   restic_0.18.0_windows_amd64_official.exe

$ busybox du -h restic_0.18.0_disablegrpcmodules.exe
28.3M   restic_0.18.0_disablegrpcmodules.exe

Which part of the docs are you referring to exactly? Installation — restic 0.18.0 documentation suggests to use go run build.go which already adds disable_grpc_modules. But yes it’s missing from Developer Information — restic 0.18.0 documentation .

Edit: docs update docs: fix typos in developer information by MichaelEischer · Pull Request #5329 · restic/restic · GitHub