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

Any plans for a Windows release? #2

Open
diegopau opened this issue Dec 22, 2024 · 10 comments
Open

Any plans for a Windows release? #2

diegopau opened this issue Dec 22, 2024 · 10 comments

Comments

@diegopau
Copy link

Hi,

I don't see any Windows builds on the Releases page, is there a way to run this with Restic for Windows? if not, do you plan to add Windows builds in the future?

Thank you in advance.

@CGamesPlay
Copy link
Owner

Hello, thanks for your interest in the project!

I don't believe there is anything in here that is specific to UNIX (and certainly nothing that wouldn't work in the Git shell for Windows), but I don't have any capacity to test it. If you'd like to give a try to compiling it for Windows and testing it out (make test), we could think about adding precompiled binaries for future versions.

@diegopau
Copy link
Author

Thanks to you for sharing this project with the world.

I have very basic skills for compiling and debugging compile issues but I will give it a try tomorrow for sure!

The first obstacle I am finding is that I am using Restic for other backups and for that I use a version that is more recent than the recommended here ( I have 0.17.1 installed so that's what is added to PATH) and I prefer not to touch that setup now that I have it running. Would there be a way to use a different version for git-remote-restic? I see that there is a "restic" folder in the repo so is it maybe an alternative to drop there the restic executable that can be downloaded from https://github.com/restic/restic/releases/tag/v0.16.4 ?

If i just run "make test" in a terminal I get the errors below but surely I have to first configure something related to restic on my end:

fatal: not a git repository (or any of the parent directories): .git
process_begin: CreateProcess(NULL, cat restic/VERSION, ...) failed.
Makefile:9: pipe: Bad file descriptor
go install -ldflags '-X "main.Version='with uncommitted changes'" -X "main.ResticVersion="' github.com/CGamesPlay/git-remote-restic/...
process_begin: CreateProcess(NULL, go install -ldflags "-X \"main.Version=with" uncommitted "changes\" -X \"main.ResticVersion=\"" github.com/CGamesPlay/git-remote-restic/..., ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [Makefile:9: install] Error 2

@CGamesPlay
Copy link
Owner

Would there be a way to use a different version for git-remote-restic?

Yes, in fact, you don't need restic installed at all. The restic folder you see is a copy of the source code of the restic CLI program; it is embedded into the git-remote-restic program. So your system version of restic will not be used or considered when compiling.

process_begin: CreateProcess(NULL, go install -ldflags "-X \"main.Version=with" uncommitted "changes\" -X \"main.ResticVersion=\"" github.com/CGamesPlay/git-remote-restic/..., ...) failed.
make (e=2): The system cannot find the file specified.

You appear to not have go installed on your system. Since git-remote-restic is written in go, you will need to get go installed in order to compile.

@diegopau
Copy link
Author

diegopau commented Dec 23, 2024

Alright I think I managed to compile it correctly! (with the help of Claude)

The Makefile would apparently require quite a few changes to work with Windows. Claude tried to fix it but it still didn't work. So then Claude proposed to directly use "go install" and that worked.

Steps I did:

Install go for Windows. I already had git installed.

Then from PowerShell:

git clone https://github.com/CGamesPlay/git-remote-restic

cd git-remote-restic

git config --file=.gitmodules submodule.restic.url https://github.com/CGamesPlay/restic.git

git submodule update --init --recursive

go install -ldflags "-X main.Version=$(git rev-parse --short HEAD) -X main.ResticVersion=0.16.4" github.com/CGamesPlay/git-remote-restic/...

After doing this a git-remote-restic.exe file is dropped here:
%USERPROFILE%\go\bin

Then I added git-remote-restic.exe to the PATH

Since I don't want to use the Restic.exe that is in PATH (it is version 17.1) I just downloaded the restic_0.16.4_windows_amd64.exe from the Restic repo and I used that one to execute the init command.

From my desktop computer I could do the initial restic repo creation and push a commit. This worked well and got this message on the terminal:
* [new branch] main -> main
which I guess it means all is good.

I then tried to clone it from my laptop and I got this error:
error creating SSH agent: "SSH agent requested but Pageant not running"

To be clear in the laptop I do not have Restic installed, but i do have git-remote-restic installed and added to the PATH. I believe that for just the cloning step that's all I need.
I am exporting the same variables for the cloning process than for when I did the init and the initial push to the restic remote... but the push worked and the clone is giving me that error.
The variables I export are:

AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
RESTIC_PASSWORD
RESTIC_REPOSITORY

if I export GIT_TRACE in PowerShell:
$env:GIT_TRACE = "1"
and then I try again doing the cloning:
git clone restic::$env:RESTIC_REPOSITORY

Then I get a set of trace commands that shows that the last command executed (the one that fails) is:
trace: start_command: git-remote-restic origin s3:s3.{rest_of_URL_which_is_correct}

So it seems to be finding git-remote-restic.exe in the path and also cloning the right URL and since it is a s3 URL the SSH related error doesn't seem to match. Do you have any idea of what I might be doing wrong?

@CGamesPlay
Copy link
Owner

go install -ldflags "-X main.Version=$(git rev-parse --short HEAD) -X main.ResticVersion=0.16.4" github.com/CGamesPlay/git-remote-restic/...

So far, so good. This is what I would expect.

error creating SSH agent: "SSH agent requested but Pageant not running"

This seems to indicate that you are trying to clone from SSH, not from restic. Or from restic over SSH, possibly. Since you didn't show how you tried to clone that, I couldn't possibly know.

Instead of jumping straight to using a real, remote restic repository, try using just a local one to verify that everything relating to git-remote-restic is working. Once that works you can upgrade to using a real S3-backed repository.

Pushing to an empty local restic repo

# From an existing git repository you want to test with
$ restic init -r local:../my-repo
enter password for new repository:
enter password again:
created restic repository f16e45b8af at local:my-repo

Please note that knowledge of your password is required to access
the repository. Losing your password means that your data is
irrecoverably lost.
$ git push restic::local:../my-repo main
Password for 'restic://none/../my-repo':
To restic::local:../my-repo
 * [new branch]      main -> main

# Confirm that there is a snapshot there
$ restic snapshots -r local:../my-repo
enter password for repository:
repository f16e45b8 opened (version 2, compression level auto)
created new cache in /.../restic
ID        Time                 Host               Tags        Paths
---------------------------------------------------------------------------------------------------------------
0e888528  2024-12-24 09:11:44  macbook-pro.local              /.../my-git-directory/.git
---------------------------------------------------------------------------------------------------------------
1 snapshots

Cloning a new repository from a local restic repo

# Creating a new clone, run this from the directory that has the my-repo directory in it
# We have to specify the branch we want to use here
$ git clone restic::local:./my-repo my-new-clone -b main
Cloning into 'my-new-clone'...

If these commands work correctly, then you can try again using a remote repository (from the same computer to keep things simple), and once that's working, try cloning from your second computer.

@diegopau
Copy link
Author

Thank you for taking all the time to go through this with me. Also since the initial target wasn't Windows, please feel free to stop me at any moment.

I followed your instructions now and I get the same SSH error even when doing it this way.
I created the repo like this (you see how I use a specific 0.16.4 restic .exe since I don't know the consequences of using the restic.exe that is in PATH which is 0.17.1. It didn't ask for a password because it was set in an env. variable. Other than that I followed your instructions:
image

In this screenshot you can see the setup quite well and also the way I am trying to clone the repo

image

@CGamesPlay
Copy link
Owner

Well, everything up to the clone looks like it worked properly.

I am not sure about the current error. It looks like it might be selecting the wrong protocol for the clone for some reason. I don't see anything about Pageant in the restic or git-remote-restic source code, but it does look like the error is coming from git-remote-restic.

If you go back into the test\git_project folder and run git fetch, does this command work correctly (it should print no output)? If it does, the next thing I would try is this alternative clone process:

mkdir my_clone
cd my_clone
git init .
git remote add origin restic::local:C:\....\restic_repo
git fetch
git checkout origin/main -b main

If this works, then it's a useable workaround for the error you're seeing, and it helps narrow the problem down.

@CGamesPlay
Copy link
Owner

Error likely comes from go-git/auth_method.go; I don't know why this method is being called since we aren't cloning from SSH.

@diegopau
Copy link
Author

image

doing it that way works!

@CGamesPlay
Copy link
Owner

Great! Now we just need to figure out what is causing git clone to attempt to use ssh. Could be a URL parsing issue (mistakenly interpreting the URL as an SSH one), or perhaps it just always defaults to SSH, which is not an error on other platforms. Assuming we can do that, we can probably turn on cross-compilation to Windows and start distributing Windows binaries in the releases.

Glad you were able to get a workaround going!

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

No branches or pull requests

2 participants