plugins
plugins copied to clipboard
os-git-backup 1.0_1 does not initialise upstream properly, does not backup any files
Important notices Before you add a new report, we ask you kindly to acknowledge the following:
- [X] I have read the contributing guide lines at https://github.com/opnsense/plugins/blob/master/CONTRIBUTING.md
- [X] I have searched the existing issues, open and closed, and I'm convinced that mine is new.
- [X] The title contains the plugin to which this issue belongs
Describe the bug I have tried configuring git-backup with repos in both gitlab.com and github.com and with both ssh and https remotes with the same effect. When using ssh I set up a valid deploy key on the repo with write access, when using https I set up a valid access token with write access.
When I run the initial configuration with no /conf/backup/gif folder present, I get the following error banner displayed at the top of the screen:
The following input errors were detected:
unknown error, check log for details
Saved settings, but remote backup failed.
In order to get past that stage I can shell into the /conf/backup/git and run git pull origin master && git push --set-upstream origin master
. The test button then seems to operate successfully but no backup is uploaded and the file list in the banner at the top of the screen is empty. All I can see in the /conf/backup/git directory is the .git subdirectory and an identity file containing my deploy key.
To Reproduce Steps to reproduce the behavior:
- Create an empty repo in github or gitlab
- Generate a deploy key with write access to the repo
- Click on System->Configuration->Backups
- Scroll down to Git
- Enter details of the repository as specified in https://docs.opnsense.org/manual/git-backup.html including the private SSH deploy key
- Click the Setup/Test Git button
- See error
Expected behavior An initial backup should be committed to the repo and pushed to the remote repository and a "Backup successful" banner should appear indicating the files that were committed and pushed.
Relevant log files From the general log: git-backup unknown error, check log for details (error: src refspec master does not match any error: failed to push some refs to 'ssh://github.com/GJKrupa/repo-name.git' )
N.B. It says master (and the checked-out branch in /conf/backup/git is master) regardless of the branch name I specify in the UI.
Environment
OPNsense 22.1.8-amd64 FreeBSD 13.0-STABLE OpenSSL 1.1.1o 3 May 2022
https://github.com/opnsense/plugins/issues/2882#issuecomment-1060328908 ??
I don't believe it's the same thing. I already read that guide before I started and set the username to 'git' in the UI. The fact that I can push/pull the repo from the command-line without modifying the remote or the creds suggests there's no access issue.
I'm seeing this too... it's so strange.
The commands that are being executed can be found in the php code here: https://github.com/opnsense/plugins/blob/8bdd618652efb969ec0855b2be85af0240bbc657/sysutils/git-backup/src/opnsense/mvc/app/library/OPNsense/Backup/Git.php#L149-L167
Looks like it's not attaching the upstream branch to the local branch. Running git push origin master
doesn't do it, you need to have that --set-upstream (or -u) flag as well.
Since it's removing and re-adding the origin every time, it should probably be running git branch -u _remote_ _branch_
for a clean update to the upstream.
Also, as an aside, I notice the code is using just git
in a number of places where it should be using {$git}
.
changed the references to git as suggested in https://github.com/opnsense/plugins/commit/db2e4bcb0610143f6cfa413c86c0c92f80dd3db0, tried syncing to GitHub on my development machine multiple times changing branches as well, but can't reproduce an issue.
It might be an idea to reproduce the steps on your end and see which error git returns when executing the exact steps from the script.
This is what I got from running the same commands (not quite in the same order but shouldn't cause any issues):
root@router:/ # mkdir /tmp/gitback-test
root@router:/ # git init /tmp/gitback-test
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:
hint: git config --global init.defaultBranch <name>
hint:
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:
hint: git branch -m <name>
Initialized empty Git repository in /tmp/gitback-test/.git/
root@router:/ # cat > /tmp/gitback-test/identity
...
root@router:/ # chmod 600 /tmp/gitback-test/identity
root@router:/ # cd /tmp/gitback-test/ && git remote remove origin
error: No such remote: 'origin'
root@router:/tmp/gitback-test # cd /tmp/gitback-test/ && git remote add origin [email protected]:GJKrupa/opnsense-plugins-2994.git
root@router:/tmp/gitback-test # cd /tmp/gitback-test/ && git config core.sshCommand "ssh -i /tmp/gitback-test/identity -o StrictHostKeyChecking=accept-new -o PasswordAuthentication=no"
root@router:/tmp/gitback-test # cd /tmp/gitback-test/ && git push origin master
error: src refspec master does not match any
error: failed to push some refs to 'github.com:GJKrupa/opnsense-plugins-2994.git'
I'm now thinking it's just failing because there aren't any commits on the branch and nothing to do with the upstream tracking at all. I get the same if I try to push a newly-initialised repo from my MacBook until I either make an empty commit (using git commit --allow-empty
) or pull the existing commits from the remote and then push.
well, if you do have the same issue as https://github.com/opnsense/plugins/issues/3050, the hook might not have committed any local changes, in which case there isn't anything to push either. haven't thought about that at first, but could very well be the case. When you remove /conf/event_config_changed.json
and the push works, it's the same issue.
After fresh install of 22.7 and import of config from 22.1 and installing os-git-backup plugin, I now have this problem as well.
The following input errors were detected:
unknown error, check log for details Saved settings, but remote backup failed.
I'm interested in "log for details" ;)
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.
After fresh install of 22.7 and import of config from 22.1 and installing os-git-backup plugin, I now have this problem as well.
Facing the same issue, just did a fresh install and restored my backup, which included git-config
with a self hosted repo. The git backups were working before. Now every time I try to Test the setup, I get:
[meta sequenceId="1"] git-backup unknown error, check log for details (error: src refspec master does not match any error: failed to push some refs to 'ssh://git.myserver.com/org/mybackuprepo.git' )
I can push when I SSH into the box, go to /conf/backup/git
and do git push origin main
(being main
the branch I have configured in the git-config settings.
Any ideas?