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

Forward restic exit code from resticprofile #410

Open
arberg opened this issue Oct 5, 2024 · 5 comments
Open

Forward restic exit code from resticprofile #410

arberg opened this issue Oct 5, 2024 · 5 comments
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@arberg
Copy link

arberg commented Oct 5, 2024

Please, pretty please, forward restic exit code from resticprofile.

I would like to be able to do automation based on exit code from restic. If restic is never called, of cause do as you decide. But if restic is invoked I can do error-handling based on the actual code, possibly choosing between different retry strategies.

Tested on 0.28.1.

PS C:\ToolsAdmin\Restic> .\resticprofile.exe bnrgit-frequent-to-tower-ssd.forget
2024/10/05 22:20:56 using configuration file: profiles.yaml
2024/10/05 22:20:56 assuming restic is at latest known version ; exec: "restic.exe": cannot run executable found relative to current directory
2024/10/05 22:20:56 Failed parsing profile section "tag": '' expected a map, got 'slice'
2024/10/05 22:20:56 profile 'bnrgit-frequent-to-tower-ssd': starting 'forget'
repository 3ed62ea6 opened (version 2, compression level max)
repo already locked, waiting up to 0s for the lock
unable to create lock in backend: repository is already locked by PID 17900 on Muaddib by MUADDIB\Administrator (UID 0, GID 0)
lock was created at 2024-10-05 22:20:45 (10.7065338s ago)
storage ID 1303b763
the `unlock` command can be used to remove stale locks
2024/10/05 22:20:56 forget on profile 'bnrgit-frequent-to-tower-ssd': exit status 11
PS C:\ToolsAdmin\Restic> $LASTEXITCODE
1
PS C:\ToolsAdmin\Restic> .\restic.exe forget
repository 3ed62ea6 opened (version 2, compression level auto)
repo already locked, waiting up to 0s for the lock
unable to create lock in backend: repository is already locked by PID 17900 on Muaddib by MUADDIB\Administrator (UID 0, GID 0)
lock was created at 2024-10-05 22:20:45 (16.7413853s ago)
storage ID 1303b763
the `unlock` command can be used to remove stale locks
PS C:\ToolsAdmin\Restic> $LASTEXITCODE
11
PS C:\ToolsAdmin\Restic>
@arberg
Copy link
Author

arberg commented Oct 5, 2024

Also if you happen to know why I get this line, i would appreciate it. I guess its something with my setup. restic.exe is in the current dir, its not on the path, so it should be executed as ./restic.exe.

Possibly its a bug i resticprofile if it use different restic invocation for checking version than for actually executing the task.

2024/10/05 22:20:56 assuming restic is at latest known version ; exec: "restic.exe": cannot run executable found relative to current directory

@creativeprojects
Copy link
Owner

Please, pretty please, forward restic exit code from resticprofile.

I would like to be able to do automation based on exit code from restic. If restic is never called, of cause do as you decide. But if restic is invoked I can do error-handling based on the actual code, possibly choosing between different retry strategies.

restic returning different error codes is a new feature actually, resticprofile hasn't caught up yet. I was planning on returning restic codes 👍🏻

About your example using locks, resticprofile can already try to unlock the repository automatically for you, documentation here: https://creativeprojects.github.io/resticprofile/usage/locks/index.html

@creativeprojects
Copy link
Owner

2024/10/05 22:20:56 assuming restic is at latest known version ; exec: "restic.exe": cannot run executable found relative to current directory

I haven't seen this error before, although I'm no longer using a Windows machine. Does the restic.exe have some weird permissions?

You can try to specify the location of the restic.exe in the global section if that helps

@creativeprojects creativeprojects added enhancement New feature or request good first issue Good for newcomers labels Oct 5, 2024
@danielfdickinson
Copy link
Contributor

danielfdickinson commented Oct 6, 2024 via email

@arberg
Copy link
Author

arberg commented Oct 6, 2024

Thank you both.

Cool to hear its a new restic feature, no wonder you were not forwarding the exit code yet.

Fred, regarding locks thank you, I know about it and appreciate that feature greatly. But thank you for the heads up. In this case the other program was running and I was considering adding some error-code handling to my scripts.

Btw. I've created powershell wrappers around restic-profile. The powershell scripts are crossplatform so can be used for both windows and linux, and I use it for both, though mostly I think its useful for the task-handling of the windows backups. Hopefully I'll publish it soon.

Thank you Daniel, it helped setting the path env, or setting the mentioned restic-binary to full path, that made the warning go away. Indeed in my case, restic was not on the path and I'm using powershell and therefore one had to run ./restic. But it worked for backup, as in resticprofile could find restic and launch the backup, so I was confused about the waning/error.

You can close this, if you don't think there's anything else to add or consider about the warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

3 participants