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

os-git-backup - error in push #4143

Closed
patrickavi opened this issue Aug 1, 2024 · 3 comments · May be fixed by #4373
Closed

os-git-backup - error in push #4143

patrickavi opened this issue Aug 1, 2024 · 3 comments · May be fixed by #4373
Labels
help wanted Contributor missing

Comments

@patrickavi
Copy link

Important notices
Before you add a new report, we ask you kindly to acknowledge the following:

Describe the bug

I use the os-git-backup plugin to back up files to the remote server. I have identified problems in the execution of the process, more specifically when the push is made to the remote server.

Via the graphical interface when clicking on setup/Test Git:

The following input errors were detected:

unknown error, check log for details
Saved settings, but remote backup failed

Whenever I manually push, the same problem occurs:

! [remote rejected] master -> master (decreased pre-received hook)
error: failed to push some refs to 'ssh://xxxxxx.xxx/backup-opn.git'

the last successful push was 7 months ago

Tip: To validate your configuration was working with the previous version, use opnsense-revert (https://docs.opnsense.org/manual/opnsense_tools.html#opnsense-revert)

To Reproduce

Backed up in the setup/Test Git option:

The following input errors were detected:

unknown error, check log for details
Saved settings, but remote backup failed

or by manually git pushing

! [remote rejected] master -> master (decreased pre-received hook)
error: failed to push some refs to 'ssh://xxxxxx.xxx/backup-opn.git'

Expected behavior
successful automatic backup or when clicking setup / test the file upload to the remote server is successful

Screenshots
N/A

Relevant log files
! [remote rejected] master -> master (decreased pre-received hook)
error: failed to push some refs to 'ssh://xxxxxx.xxx/backup-opn.git'

Additional context

pulling works normally
reinstall plugin
remove permissions from the remote repository to the point of leaving any pushes free
push -f
remove /conf/backup/git and event_config_changed.json

Environment

OPNsense 24.1.9_4
Gitlab remote repo
pull ok

@VisibleSampling
Copy link

VisibleSampling commented Nov 30, 2024

I rotated some SSH keys recently and have started to encounter this error as well. After looking into it a bit further I have identified the cause.

When you apply the configuration in the GUI and hit Setup/Test Git the plugin overwrites /conf/backup/git/.git/config with the new configuration. However it is missing the [remote "origin"] portion of the file and git is unable to push until you set a new origin.

By manually adding the origin the push to git does work as expected.

After looking at the source for the plugin I noticed that its hardcoded to look for a master branch on line 165 of Git.php.

I was able to do the following as work around:

cd /conf/backup/git
git checkout -b master  # Create local master branch
git branch --set-upstream-to=origin/main master  # Make it track remote main

@wommy
Copy link

wommy commented Dec 19, 2024

i just spent 3 hours on this

had no clue where my key was, bc afaik
the docs has you create the keys on a separate host and upload them?

why?

also the docs could use examples,
i remember whenever i got it working,
i first failed 10x in the span of hours, if not sessions

the current workflow
seems extremely brittle
recovery should be robust

i was successful in the end,
but only because im familiar with git

i easily could have borked the pull or the merge
n lost ~9 months of config iterations

why?

my major mistake was deleting my github deploy key
i thought the workflow would be as simple as

  • delete gh key
  • spin up new key
  • create new deploy key

but i ended up mucking about in
/conf/backup/git and /usr/local/opnsense/mvc/app/library/OPNsense/Backup/Git.php
for a lifetime

the issue totally stems from github using main and master being hard-coded

while your solution #4373
addresses one of the unhappy paths,
i think theres numerous other ways people can get snagged

it seems like the whole system could use an overhaul
at very least the docs do

sorry if my tone was curt, this entire process was
very involved,
time-consuming,
and possibly fatal
at every twist and turn

but i endured and was successful,
but i doubt the average joe would share my success

im willing to help in anyway possible

theres many many many issues around this
https://github.com/opnsense/plugins/issues?q=is%3Aissue+os-git-backup

also in trying to nail down what started this bug
my last successful push was ~March 8th?
i didn't make another config change until the 22nd and it was broke by then
it should be easy to track down the opnsense version in that gap


aside:
i think #4051 is related

@OPNsense-bot
Copy link

This issue has been automatically timed-out (after 180 days of inactivity).

For more information about the policies for this repository,
please read https://github.com/opnsense/plugins/blob/master/CONTRIBUTING.md for further details.

If someone wants to step up and work on this issue,
just let us know, so we can reopen the issue and assign an owner to it.

@OPNsense-bot OPNsense-bot closed this as not planned Won't fix, can't repro, duplicate, stale Jan 28, 2025
@OPNsense-bot OPNsense-bot added the help wanted Contributor missing label Jan 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Contributor missing
Development

Successfully merging a pull request may close this issue.

4 participants