Low-Frequency/Klipper-Git-Backup

Not getting commits

Closed this issue · 5 comments

Sorry to bother you again, I feel like I've done something to break this, whilst I was trying to get GIT working yesterday.

Has worked, then stopped updating changes overnight.

`nothing to commit, working tree clean
[2022-04-21 12:07:46]: Pushing
[2022-04-21 12:07:48]: Log rotation is disabled
[2022-04-21 12:07:49]: Backing up to GitHub
[2022-04-21 12:07:49]: Adding changes to push
[2022-04-21 12:07:49]: Committing to GitHub repository
On branch main
Your branch is ahead of 'origin/main' by 3 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean
[2022-04-21 12:07:49]: Pushing
[2022-04-21 12:07:50]: Log rotation is disabled
[2022-04-21 12:07:51]: Backing up to GitHub
[2022-04-21 12:07:51]: Adding changes to push
[2022-04-21 12:07:51]: Committing to GitHub repository
On branch main
Your branch is ahead of 'origin/main' by 3 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean
[2022-04-21 12:07:51]: Pushing
[2022-04-21 12:07:53]: Log rotation is disabled
[2022-04-21 12:07:54]: Backing up to GitHub
[2022-04-21 12:07:54]: Adding changes to push
[2022-04-21 12:07:54]: Committing to GitHub repository
On branch main
Your branch is ahead of 'origin/main' by 3 commits.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean
[2022-04-21 12:07:54]: Pushing`

I've changes in my printer.cfg, yet nothing uploaded to github.

What did I do?

J

That's a weired issue if it just started randomly.

Try a manual backup with

git -C "$HOME/klipper_config" add .
git -C "$HOME/klipper_config" commit -m "manual backup"
git -C "$HOME/klipper_config" push -u origin main

If the manual backup fails the problem shouldn't be caused by the script itself.

If the backup is successful and you're using backup intervals try decreasing the intervals in the config and restart the pi afterwards. It might be that Git doesn't like frequent pushes to the same repo.

If that doesn't help I might have to try to replicate this issue on the weekend to see what exactly fails.

I wonder if this is because I added a readme?

 ! [rejected]        main -> main (fetch first)
error: failed to push some refs to 'github.com:e1w00db1ue5/klipper_backup.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

Okay, I see what you did there. I guess you have edited a file in the repository via the web IDE, or manually uploaded a new file directly to the repository? If so, that breaks the script.
Git assumes the version in the repository (on GitHub) is the one and only truth/the source. If there's changes in your local copy, you have to push the changes to the source. If there are changes in the source you don't have locally, you have to pull from the source. Pulling from the source merges all changes from the source and the local changes you've done, however it can get weired if you have conflicting changes (e.g. you've edited a line via the web IDE, but you have deleted this line locally).

The script doesn't catch the second workflow since it is supposed to be a backup and you shouldn't edit backups. All changes should be done locally.

To fix it, you have to pull the changes you've done. This can be done with git -C ~/klipper_config pull.

Sorry for slow response, quick pull with rebase and we're all working again. Thank you for your help.

No problem. I'm glad you got it figured out.