Staubgeborener / Klipper-Backup

Klipper backup script for manual or automated GitHub backups. Lightweight, pragmatic and comfortable.
https://klipperbackup.xyz
271 stars 52 forks source link

Fixes Issue #6 , Improvements, Changes, Added Feature #24

Closed Tylerjet closed 8 months ago

Tylerjet commented 8 months ago

This does have breaking changes due to the new paths used for folder and files, see .env.example for new structure to follow

Staubgeborener commented 8 months ago

I merged the code for testing into the dev branch. Is this code working on your side?

Running the script.sh for the first time leads to this output

Skipping symbolic link: /home/pi/printer_data/config/KAMP
Skipping symbolic link: /home/pi/printer_data/config/mainsail.cfg
Skipping file: /home/pi/printer_data/config/printer-20230528_174042.cfg
Skipping file: /home/pi/printer_data/config/printer-20230720_133952.cfg
Skipping file: /home/pi/printer_data/config/printer-20230720_135620.cfg
Skipping file: /home/pi/printer_data/config/printer-20230720_140934.cfg
Skipping symbolic link: /home/pi/printer_data/config/timelapse.cfg
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 /home/pi/config_backup/.git/
New backup from 10-01-24
[master (root-commit) 1d4eade] New backup from 10-01-24
 15 files changed, 1718 insertions(+)
 create mode 100644 README.md
 create mode 100644 klipper/GET_PROBE_LIMITS.cfg
 create mode 100644 klipper/adxl.cfg
 create mode 100644 klipper/crowsnest.conf
 create mode 100644 klipper/macros.cfg
 create mode 100644 klipper/moonraker.conf
 create mode 100644 klipper/pa_cal.cfg
 create mode 100644 klipper/pa_flow_calibrate.cfg
 create mode 100644 klipper/printer.cfg
 create mode 100644 klipper/saved_variables.cfg
 create mode 100644 klipper/secrets.conf
 create mode 100644 klipper/shell_command.cfg
 create mode 100644 klipper/sonar.conf
 create mode 100644 klipper/sounds.cfg
 create mode 100644 klipper/telegram.conf
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/Staubgeborener/klipper-backup-test-dev.git'

Running it a second time:

Skipping symbolic link: /home/pi/printer_data/config/KAMP
Skipping symbolic link: /home/pi/printer_data/config/mainsail.cfg
Skipping file: /home/pi/printer_data/config/printer-20230528_174042.cfg
Skipping file: /home/pi/printer_data/config/printer-20230720_133952.cfg
Skipping file: /home/pi/printer_data/config/printer-20230720_135620.cfg
Skipping file: /home/pi/printer_data/config/printer-20230720_140934.cfg
Skipping symbolic link: /home/pi/printer_data/config/timelapse.cfg
New backup from 10-01-24
On branch master
nothing to commit, working tree clean
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/Staubgeborener/klipper-backup-test-dev.git'

And truly, there is no new push in my backup GitHub repository. So in the end I had to handle this error

 Using 'master' as the name for the initial branch. This default branch name
[...]
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/Staubgeborener/klipper-backup-test-dev.git'

I added git branch -M main after git config init.defaultBranch main to get rid of it (example). After running script.sh again, I get a successful push in my backup GitHub repository.

Staubgeborener commented 8 months ago

So far, I tested the following:

Tylerjet commented 8 months ago

I merged the code for testing into the dev branch. Is this code working on your side?

Running the script.sh for the first time leads to this output

Skipping symbolic link: /home/pi/printer_data/config/KAMP
Skipping symbolic link: /home/pi/printer_data/config/mainsail.cfg
Skipping file: /home/pi/printer_data/config/printer-20230528_174042.cfg
Skipping file: /home/pi/printer_data/config/printer-20230720_133952.cfg
Skipping file: /home/pi/printer_data/config/printer-20230720_135620.cfg
Skipping file: /home/pi/printer_data/config/printer-20230720_140934.cfg
Skipping symbolic link: /home/pi/printer_data/config/timelapse.cfg
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 /home/pi/config_backup/.git/
New backup from 10-01-24
[master (root-commit) 1d4eade] New backup from 10-01-24
 15 files changed, 1718 insertions(+)
 create mode 100644 README.md
 create mode 100644 klipper/GET_PROBE_LIMITS.cfg
 create mode 100644 klipper/adxl.cfg
 create mode 100644 klipper/crowsnest.conf
 create mode 100644 klipper/macros.cfg
 create mode 100644 klipper/moonraker.conf
 create mode 100644 klipper/pa_cal.cfg
 create mode 100644 klipper/pa_flow_calibrate.cfg
 create mode 100644 klipper/printer.cfg
 create mode 100644 klipper/saved_variables.cfg
 create mode 100644 klipper/secrets.conf
 create mode 100644 klipper/shell_command.cfg
 create mode 100644 klipper/sonar.conf
 create mode 100644 klipper/sounds.cfg
 create mode 100644 klipper/telegram.conf
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/Staubgeborener/klipper-backup-test-dev.git'

Running it a second time:

Skipping symbolic link: /home/pi/printer_data/config/KAMP
Skipping symbolic link: /home/pi/printer_data/config/mainsail.cfg
Skipping file: /home/pi/printer_data/config/printer-20230528_174042.cfg
Skipping file: /home/pi/printer_data/config/printer-20230720_133952.cfg
Skipping file: /home/pi/printer_data/config/printer-20230720_135620.cfg
Skipping file: /home/pi/printer_data/config/printer-20230720_140934.cfg
Skipping symbolic link: /home/pi/printer_data/config/timelapse.cfg
New backup from 10-01-24
On branch master
nothing to commit, working tree clean
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/Staubgeborener/klipper-backup-test-dev.git'

And truly, there is no new push in my backup GitHub repository. So in the end I had to handle this error

 Using 'master' as the name for the initial branch. This default branch name
[...]
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/Staubgeborener/klipper-backup-test-dev.git'

I added git branch -M main after git config init.defaultBranch main to get rid of it (example). After running script.sh again, I get a successful push in my backup GitHub repository.

Was the script ran in a folder that already was initialized? as yes that code all ran fine from a fresh repo and folder, I do now realize an oversight on my behalf, right now the script is under the impression that the folder either does not have the .git folder (so no initialized repo, or that they are following the soon to be new standard of using a main branch instead of master as the default.

I'll look at a way to add a check to find the branch they are on or create the main branch if its a first time install.

Tylerjet commented 8 months ago

slight edit to the above need to look into the default branch as was able to reproduce by pulling any reference to defaultBranch in global and system git config settings for some reason git is not following the config command just after init like it should be

Staubgeborener commented 8 months ago

? Your edit is not in this PR

Tylerjet commented 8 months ago

? Your edit is not in this PR

whoops meant edit to the above comment, though i have found a solution just testing it now

Tylerjet commented 8 months ago

Alright adjusted the README.md, as well added that update check to the beginning and my modifications for the repository branch are in there as well, improved it a bit more so that you can now set the name of the branch. If a user does not want main they can change it. As well as grabbing the branch name if .git already exists.

Staubgeborener commented 8 months ago

Just let me know as soon as you're done with the commits and your work

Tylerjet commented 8 months ago

@Staubgeborener That should be it for those changes.