Coder Social home page Coder Social logo

staubgeborener / klipper-backup Goto Github PK

View Code? Open in Web Editor NEW
256.0 9.0 49.0 1.42 MB

Klipper backup script for manual or automated GitHub backups. Lightweight, pragmatic and comfortable.

Home Page: https://klipperbackup.xyz

Shell 100.00%
3d-printing backup backup-script fluidd git klipper mainsail octoprint shell moonraker

klipper-backup's Introduction

Klipper-Backup 💾

Klipper-Backup is a script for manual or automated GitHub backups. It's Lightweight, pragmatic and comfortable.

Installation

Download:

curl -fsSL get.klipperbackup.xyz | bash

Installation/Configuration:

~/klipper-backup/install.sh

RTFM

I would suggest reading the docs, as this provides detailed step-by-step instructions and further tips.

YouTube

There are several YouTube videos about Klipper-Backup - thanks to everyone!

klipper-backup's People

Contributors

staubgeborener avatar thezoker avatar tylerjet avatar ziti avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

klipper-backup's Issues

Entire printer_data folder support?

Is it possible to backup the entire printer_data folder to a git repo, or must we define each individual file?

I was going to backup the entire folder and use .gitignore to exclude certain folders like logs that I don't need in a repo, but as I add more files, I don't want to have to remember to add them.

I attempted to add a folder to the configuration and it said I didn't specific -R but if I added that, the script blew up.

Need to restore my configs to a "recovered" printer, not familiar enough with Git

Could you make a quick writeup on how to clone the existing repo down to a new install, and what steps would then be required to have it start pushing changes up to the repo.

My SD card died, awesome that I have my configs backed up. Ideally I'd like to be able to "pull" the existing configs down, without manual copying.

New feature: individual commit messages

I wanted to be able to set individual commit messages, as it makes it easier to find specific changes in the commit history.

I found a way to enable just that, with a parameter in the macro. It's not ideal, as you have to wrap the message in double-quotes (otherwise it will fail), but it's good enough for me.
You can find my (backwards-compatible) code-changes in script.sh and the macro needed in my commit https://github.com/cherub-i/klipper-backup/commit/68e7e72762012b8b75c324d1970f64693773ff15

Repo has untracked source files: ['klippy/extras/gcode_shell_command.py'

First let me say. I appreciate the work that went into this project.
I got it running. I am using the manual backup variant.
I added the macros to just have the "Update Git" functionality. It reliably pushes backups to my repo on GitHub.
So no problems there but as a result of adding the "gcode_shell_command" and the macros I now get a info notification in the Mainsail Update Manger next to the "Klipper up to date" which says [Repo has untracked source files: ['klippy/extras/gcode_shell_command.py']

Does anyone have a idea what this means, what is wrong and how it could be fixed?

Klipper notification

[Bug]:

What happened

// ! [rejected] main -> main (non-fast-forward)
01:11:31 PM
// error: failed to push some refs to 'https://github.com/TItan371/MinionKlipperBackUP.git'
01:11:31 PM
// hint: Updates were rejected because the tip of your current branch is behind
// hint: its remote counterpart. Integrate the remote changes (e.g.
// hint: 'git pull ...') before pushing again.
// hint: See the 'Note about fast-forwards' in 'git push --help' for details.
01:11:31 PM
// Command {update_git_script} finished

What did you expect to happen

update finish

How to reproduce

run script.sh

Additional information

01:11:25 PM
// Running Command {update_git_script}...:
01:11:26 PM
// Klipper-backup is up to date
01:11:27 PM
// hint: Pulling without specifying how to reconcile divergent branches is
// hint: discouraged. You can squelch this message by running one of the following
// hint: commands sometime before your next pull:
// hint:
// hint: git config pull.rebase false # merge (the default strategy)
// hint: git config pull.rebase true # rebase
// hint: git config pull.ff only # fast-forward only
// hint:
// hint: You can replace "git config" with "git config --global" to set a default
// hint: preference for all repositories. You can also pass --rebase, --no-rebase,
// hint: or --ff-only on the command line to override the configured default per
// hint: invocation.
01:11:29 PM
// From https://github.com/TItan371/MinionKlipperBackUP
// * branch main -> FETCH_HEAD
01:11:29 PM
// 1c88d65..9e10ff9 main -> origin/main
01:11:29 PM
// fatal: refusing to merge unrelated histories
01:11:29 PM
// Skipping symbolic link: printer_data/config/fluidd.cfg
01:11:29 PM
// Skipping symbolic link: printer_data/config/KAMP
01:11:29 PM
// Skipping symbolic link: printer_data/config/K-ShakeTune
01:11:29 PM
// Skipping symbolic link: printer_data/config/timelapse.cfg
01:11:29 PM
// On branch main
// nothing to commit, working tree clean
01:11:30 PM
// From https://[email protected]/TItan371/MinionKlipperBackUP.git
01:11:31 PM
// To https://github.com/TItan371/MinionKlipperBackUP.git
// ! [rejected] main -> main (non-fast-forward)
01:11:31 PM
// error: failed to push some refs to 'https://github.com/TItan371/MinionKlipperBackUP.git'
01:11:31 PM
// hint: Updates were rejected because the tip of your current branch is behind
// hint: its remote counterpart. Integrate the remote changes (e.g.
// hint: 'git pull ...') before pushing again.
// hint: See the 'Note about fast-forwards' in 'git push --help' for details.
01:11:31 PM
// Command {update_git_script} finished

​env file

github_username=TItan371
github_repository=MinionKlipperBackUP
branch_name=main
commit_username="TItan371"

Im trying to install the program with my own fork because the update manager states "Dirty". I have tried installing the program several times, but im always getting this error in the Initialization step:

pi@vyper:~/klipper-backup $ cd ~/klipper-backup
sudo rm -r .git
git init
git add .
git commit -m "create repository"
git branch -M main
git remote add origin https://github.com/SejeAnd/Vyper.git
git push -u origin main
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
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
Initialized empty Git repository in /home/pi/klipper-backup/.git/
warning: adding embedded git repository: klipper-backup
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
hint: If you meant to add a submodule, use:
hint:
hint: git submodule add klipper-backup
hint:
hint: If you added this path by mistake, you can remove it from the
hint: index with:
hint:
hint: git rm --cached klipper-backup
hint:
hint: See "git help submodule" for more information.
Author identity unknown

*** Please tell me who you are.

Run

git config --global user.email "[email protected]"
git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'pi@vyper.(none)')
error: src refspec main does not match any
error: failed to push some refs to 'https://github.com/SejeAnd/Vyper.git'

Question regarding configuration (v1.0.0)

Hello and thanks for creating this plugin!

I am a confused by the ".env.example" file. There is an example of "backup_folder=config_backup/klipper" that is supposedly used to back up a folder. In the Wiki under "Installation: Configuration", you mention "All files defined here....must start with path_ followed by the path". There is no mention of using backup_ in the Wiki. Is this a valid command for v1.0.0 or should we just use path_? If we can use backup_, can you add that documentation also to the Wiki?

Thinking about it more...is this the path that you use to sync the files to GitHub? If you could explain this inline as comment in the .env what the purpose of this path is and if we can edit or not, that would be nice.

I am also confused by this:
path_klipperdata=printer_data/config/*
#path_macroscfg=printer_data/macros/*
path_singlefile=printer_data/config/singlefile.cfg

What is the context of using either klipperdata, macroscfg or singlefile after path_? Can we make those whatever we want? What do they correspond to? Do they set up folders that then sync to GitHub for organization? Some elaboration would be appreciated :)

Fixing moonraker "dirty" flag error - Time for testing

Ok guys @MallocArray, @jaakko000 @Rvh91, I need some help to test this. A separate issue should help to keep the overview, because this is a little bit very special.

I created a new branch called dev.

There you can find a new install.sh script which tries to fix this dirty moonraker flag issue.

Idea: The user downloads the repository as it is, during installation you will be asked to enter the path of your "true" backup folder. You have to edit the .env file in this "true" backup folder like you did before in the klipper-backup folder. As soon as a new update is ready, it will be loaded in the klipper-backup folder, then the script looks up the path to the "true" backup folder and copies all relevant files there (except the .env).

How to do it, step by step:

  1. Fork this project (remove the checkmark at 'Copy the main branch only'!)
  2. Clone the repository from your account: git clone -b dev https://github.com/yourownaccount/klipper-backup/
  3. cd ./klipper-backup && chmod +x *.sh
  4. ./install.sh
  5. The script will ask for the "true" backup folder, enter something like /home/pi/myownklipperbackup (it's up to you)
  6. Check if it worked: ls -al /home/pi/myownklipperbackup
  7. Edit the .env file in your own backlog folder not the one in klipper-backup!
  8. Now you have to initialize the "true" backup folder git repository like this. ATTENTION: cd /home/pi/myownklipperbackup is not correct anymore! Instead, do cd ~/klipper-backup
  9. Now you can change some files in your forked repository (see step 1). Moonraker should see that and tells you about a new update.
  10. Hopefully this will work

GitHub access token found in commit

When i insert github_token into .env and push by "bash script.sh" inside ~/klipper-backup in SSH, github instantly revokes my access token. Is the repo supposed to be private or something? Doesnt seem to matter if its a fine grain or normal token.

Unclear, what that means and what to do

  1. "The branch name defined in .env does not match the branch that is currently checked out, to remove this warning update branch_name in .env to" --> i have the branch "main" in git and the .env "branch_name=mainbranch_name=main". I also tried "head", but that did not help

  2. Von https://github.com/Experiment4/Evolux

  • branch HEAD -> FETCH_HEAD
    fatal: Es sieht so aus, als ob es das Verzeichnis rebase-merge bereits gibt
    und es könnte ein anderer Rebase im Gange sein. Wenn das der Fall ist,
    probieren Sie bitte
    git rebase (--continue | --abort | --skip)
    Wenn das nicht der Fall ist, probieren Sie bitte
    rm -fr ".git/rebase-merge"
    und führen Sie diesen Befehl nochmal aus. Es wird angehalten, falls noch
    etwas Schützenswertes vorhanden ist.

fatal: ungültige Refspec ''

--> wie bekomme ich diese Meldung weg, bzw. so hin, dass das backup richtig läuft ?

(RESOLVED) fatal: loose object, and related errors

Code of Conduct

  • I promise that i have used markdown syntax to make the code more readable which helps to fix the problem

What happened

I had the backup set up on my main printer which I've used KIAUH on MX Linux (using SystemD kernel) it was working last month and now no longer works, I tried reinstalling on secondary printer and get the same error, following the install instructions to the letter, to make sure I had not done something wrong, I get the same error on the secondary system as I did the first, I have tried a few google search result fixes and nothing seems to fix the issue

What did you expect to happen

for the macro to backup my my config's to github

How to reproduce

just running it via macro or even running it via terminal script.sh

Additional information

No response

Incremental local copy with rsync

Script uses cp -r to copy files to the git directory.
This always copies all files and overwrites existing ones instead of just the changed ones adding unneeded wear to sd-cards
instead rsync -a should be used.
This only copies actually changed/new files.
If one wants to be paranoid rsync -a --checksum could be used so every file is actually checkum compared.

Updates rejected...remote contains work that is not local

Trying to set up this plugin and when I try and push my files to my GitHub repo, I am faced with this error:

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.

Any thoughts on what I am doing wrong?

[Feature request]: Can Add something in the Automated Backups Doc?

Is your feature request related to a problem? Please describe.

Because I'm using CB1, the link is not /home/mks/klipper-backup/script.sh, it is /home/biqu/klipper-backup/script.sh, and the user is also different, is not root, is biqu.

Describe the solution you'd like

So can add the warning about the different link and the username?

Describe alternatives you've considered

Or another way to remind you about these two?

Additional information

No response

[Bug]: fail to start klipper backup service

What happened

When running sudo systemctl start klipper-backup.service, I do get the error
● klipper-backup.service - Klipper Backup Service Loaded: loaded (/etc/systemd/system/klipper-backup.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sat 2024-02-03 19:37:40 CET; 15s ago Process: 2523 ExecStart=/bin/bash -c /home/mks/klipper-backup/script.sh "New Backup on boot $(date +%D)" (code=exited, status=217/USER) Main PID: 2523 (code=exited, status=217/USER) CPU: 0

Running journalctl -xe I do get

The unit klipper-backup.service has entered the 'failed' state with result 'exit-code'. Feb 03 19:35:02 mainsail systemd[1]: Failed to start Klipper Backup Service. ░░ Subject: A start job for unit klipper-backup.service has failed ░░ Defined-By: systemd ░░ Support: https://www.debian.org/support ░░ ░░ A start job for unit klipper-backup.service has finished with a failure. ░░ ░░ The job identifier is 1117 and the job result is failed. Feb 03 19:35:02 mainsail sudo[2480]: pam_unix(sudo:session): session closed for user root Feb 03 19:36:23 mainsail python[690]: [websockets.py:on_close()] - Websocket Closed: ID: 3888790688 Close Code: 1001, Close Reason: None, Pong Time Elapsed: 6.22 Feb 03 19:37:40 mainsail sudo[2520]: arne : TTY=pts/1 ; PWD=/home/arne ; USER=root ; COMMAND=/usr/bin/systemctl start klipper-backup.service Feb 03 19:37:40 mainsail sudo[2520]: pam_unix(sudo:session): session opened for user root(uid=0) by arne(uid=1000) Feb 03 19:37:40 mainsail systemd[2523]: klipper-backup.service: Failed to determine user credentials: No such process Feb 03 19:37:40 mainsail systemd[2523]: klipper-backup.service: Failed at step USER spawning /bin/bash: No such process ░░ Subject: Process /bin/bash could not be executed

What did you expect to happen

Expected it to starts

How to reproduce

Installed like described in the wiki into the regular home folder on a mainsail system on a raspberry pi 4b

Additional information

I hope I didnt bother you too much, but I dont know what to do anymore.

Regards Arne :)

Suggestion for the Q&A

Hi, thanks for this great script.
I have been playing around with it and was wondering how to secure the mainsail folders for myself.
In the Q&A only subfolders are mentioned.
But this works for every folder (maybe only inside home folder?)
So my suggestion would be to adjust the Q&A accordingly so that it is more obvious that other folders can also be backed up. And not only subfolders

[Feature request]: Execute automatically when config changed

Is your feature request related to a problem? Please describe.

Backups on boot or with Cron are fine, but actually I just need a backup when I changed things in one of the config-files.

Describe the solution you'd like

It would be ideal to trigger a backup, only when a config-file has been added, modified or deleted. However, many of my config-files are co-related, so during major changes there should be a marco/switch, to temporarily disable the "update-on-change-feature" .

Additional information

Great project! Looked forward to something like this for a looong time! 😊

[Bug]: Unable to push to repo due to compressing error

What happened

After running ./script.sh the compressing procedure takes a while and the upload fails.
image

What did you expect to happen

Pushing configfiles to repository

How to reproduce

unable to tell

Additional information

No response

"corrupt" error

I cant seem to figure out whats causing this "corrupt" error, when I click hard recovery it shows a user name error but my user name is correct in the .env and my files back up just fine. I have tried reinstalling everything from scratch but no change. I also get this other warning while using the backup script from ssh, not sure its related. I also can't figure out why my two of my .cfg don't show up in GitHub with the actual contents but instead just show the file path also pictured below.

Screenshot 2023-10-05 at 08 02 47 Screenshot 2023-10-05 at 07 46 29 Screenshot 2023-10-05 at 07 44 57 Screenshot 2023-10-05 at 07 45 09 Screenshot 2023-10-05 at 07 45 46

Feature request: incremental backups

It would be nice not to reinit whole repo all the time, and push only things that was changed. That is git natural behaviour, and that will allow to look through the history of the changes over time, which could be really helpful.

Missing instruction for copying .env.example to .env

When following the Wiki, this is the first page that I saw it talk about the .env file
https://github.com/Staubgeborener/klipper-backup/wiki/Configuration

It starts with saying to open the .env file, but at this stage, I believe it exists as .env.example only. I did cp .env.example .env to make a copy and then edited the new .env file

Perhaps this is common knowledge, but I could see it tripping up some users, especially with the file being hidden.

Primary setup command doesn't work

Code of Conduct

  • I promise that i have used markdown syntax to make the code more readable which helps to fix the problem

What happened

I entered git clone https://github.com/Staubgeborener/klipper-backup.git && chmod +x ./klipper-backup/script.sh && cp ./klipper-backup/.env.example ./klipper-backup/.env into my terminal

What did you expect to happen

I expected it would create the .env file in my folder, it only placed the ReadMe and the Script into my folder, and there was no .env file created.

How to reproduce

SSH into Raspberry Pi, run the command, check the contents of the folder.

Additional information

Instructions seem to lack any guidance of WHERE to run this command from within your installation. Running it at the root folder makes it unclear where the new folder is created, I can't find it in WinSCP. And running it in the Klipper folder puts it into a new folder, but again it only contains the 2 files. Very confusing.

Commit username

Let me start by saying that I have very little github experience but many of us are just using our klipperized 3d printers and want a nice backup solution so we are using this.

Currently the latest update on 1/12 fixed my issue that i had where it wouldn't backup at all. I received
fatal: could not read password for 'https://[email protected]' : no such device or address and would not work at all.

Now the backup works fine with the newest update but all the commits show Mahallon as the user.
I attempted to edit the comit username in the .env file but nothing seems to change.

all goes well until Execute

Hi there,
I am stuck,
I managed to follow the wiki, create a repository, a token, install moonraker support, initialize the Github repository,
I was going to open the .env file but there was only a .env.example file. I went ahead and created a .env file and used the example as a template.
I configured everything in this new .env file with proper path of all my config files.

Did I mention that I installed it not on a raspberry pi but on a inovato quadra. I corrected all the file path to the correct directories.

This here is what I am getting when I execute ~/klipper-backup/script.sh

~/klipper-backup/script.sh grep: /home/quadra/klipper-backup/.env: No such file or directory
grep: /home/quadra/klipper-backup/.env: No such file or directory
grep: /home/quadra/klipper-backup/.env: No such file or directory
grep: /home/quadra/klipper-backup/.env: No such file or directory
grep: /home/quadra/klipper-backup/.env: No such file or directory
Reinitialized existing Git repository in /home/quadra/klipper-backup/.git/
WARNING: git-filter-branch has a glut of gotchas generating mangled history
rewrites. Hit Ctrl-C before proceeding to abort, then use an
alternative filtering tool such as 'git filter-repo'
(https://github.com/newren/git-filter-repo/) instead. See the
filter-branch manual page for more details; to squelch this warning,
set FILTER_BRANCH_SQUELCH_WARNING=1.
Proceeding with filter-branch...

Rewrite 65b48be (1/42) (0 seconds passed, remaining 0 predicted) fatal: /.env: '/.env' is outside repository at '/home/quadra/klipper-backup/.git-rewrite/t'
index filter failed: git rm -r --cached --ignore-unmatch "$parent_path"/.env
On branch main
Your branch is up to date with 'origin/main'.

nothing to commit, working tree clean
Username for 'https://github.com': Heiko910

Any help would be appreciated

Backup not including subfolders

Backup is not including subfolders:

cp: -r not specified; omitting directory '/home/pi/printer_data/config/macros'

got a workaround by changing

cp $file $HOME/$backup_folder/
in the sript.sh to

  `cp -r $file $HOME/$backup_folder/`

is there an other way to do it?

Skript asks for password after update to newest version

Code of Conduct

  • I promise that i have used markdown syntax to make the code more readable which helps to fix the problem

What happened

I made a successful backup and the script showed, that a new version is available.

I updated with the command: cd ~/klipper-backup && git pull

After this update i get asked for a password when i want to do a backup.

What did you expect to happen

Successful backup

How to reproduce

Update from version 1.2.0 with the command: cd ~/klipper-backup && git pull

Additional information

No response

install.sh overwrites git clone

git clone https://github.com/Staubgeborener/klipper-backup klipper-backup-main chmod +x ./klipper-backup-main/*.sh && ./klipper-backup-main/install.sh

this installs the older code in the release.
example without the "cp -r" in the backup script

One slight wiki adjustment i noticed was incorrect

@Staubgeborener
on this page: https://github.com/Staubgeborener/klipper-backup/wiki/Installation%3A-Configuration#env:~:text=You%20could%20also%20use%20backup_folder%3D.%20for%20example

The line: You could also use backup_folder=. for example

The code block should be backup_folder=config_backup as that is the root of the backup repository, using backup_folder=. would make the script create the files directly in the users home directory /home/{username} which we don't want to happen as then their entire home directly will become a git repo hehe.

Which now gives me an idea of placing in a function to check if that variable does equal . so that it can warn the users. Will look into that maybe later this week when work is less hectic.

I can't get this script to work for me

I run the script, and this is what I get. I tried running the command it suggested, but that didn't work for me. Any ideas what I need to do?

pi@elf:~ $ ./klipper-backup/script.sh Reinitialized existing Git repository in /home/pi/klipper-backup/.git/
fatal: pathspec '/home/pi/klipper-backup/.env' did not match any files
On branch master
nothing to commit, working tree clean
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

git push --set-upstream https://[email protected]/simpat1zq/elf.git master

pi@elf:~ $ git push --set-upstream https://[email protected]/simpat1zq/elf.git master
fatal: not a git repository (or any of the parent directories): .git
pi@elf:~ $

Adding klipper-backup block to moonraker.cfg not showing in Mainsail

I added the klipper-backup block to moonraker.conf as show in the wiki:

[update_manager klipper-backup]
type: git_repo
path: ~/klipper-backup
origin: https://github.com/Staubgeborener/klipper-backup.git
managed_services: klipper
primary_branch: main

I don't see anything wrong with this block compared to others I have added, however klipper-backup does not show up in my Mainsail Update Manager section. Maybe there is a limitation to Moonraker?

image

The Moonraker log file doesn't show any mention of klipper-backup in the update manager. I've attached the file.
logs-20240111-121345.zip

Moonraker update manager issue

It's recommended to use moonraker update manager to update the script, but after first backup is done, update manager says that the repo is invalid. The fix button moves repo to ok state, but backup would fail after that untill you roll back all backups in backup repo.
image

Duplicate folders

With the first commit, the files and folders are uploaded as expected:

Klipper (folder)
--configs (folder)
----klicky.cfg
----macros.cfg
----display.cfg
--KAMP (folder)
----adaptive_meshing.cfg
----adaptive_purging.cfg
printer.cfg
mainsail.cfg
moonraker.conf
sonar.cfg
crownsnest.conf
KAMP_Settings.cfg

After a reboot, the folders are duplicated and moved below the original folder. All files are duplicated, too

Klipper (folder)
--configs (folder)
----configs (folder)
------klicky.cfg
------macros.cfg
----display.cfg
----klicky.cfg
----macros.cfg
----display.cfg
--KAMP (folder)
----KAMP (folder)
------adaptive_meshing.cfg
------adaptive_purging.cfg
----adaptive_meshing.cfg
----adaptive_purging.cfg
printer.cfg
mainsail.cfg
moonraker.conf
sonar.cfg
crownsnest.conf
KAMP_Settings.cfg

This is the .env:

github_token=XXX
github_username=XXXX
github_repository=XXX

path_printercfg=/home/pi/printer_data/config/printer.cfg
path_mainsailcfg=/home/pi/mainsail-config/mainsail.cfg
path_moonrakercfg=/home/pi/printer_data/config/moonraker.conf
path_sonarcfg=/home/pi/printer_data/config/sonar.conf
path_crowsnestcfg=/home/pi/printer_data/config/crowsnest.conf
path_kampsettingscfg=/home/pi/printer_data/config/KAMP_Settings.cfg

path_configsfolder=/home/pi/printer_data/config/configs/
path_KAMPfolder=/home/pi/printer_data/config/KAMP/

backup_folder=klipper

Individual commit message with "Klipper Macro"

Did you read the wiki?

  • [x ] Yes
  • No

Describe the bug
A clear and concise description of what the bug is.
I have created a klipper macro with a parameter. The side from gcode_shell_command is working and they are passing the arguments with an array to the called bash script.
So i created a github issue dw-0/kiauh#425

I think when you change your lines

if [ -n "$1" ]; then
    commit_message="$1"

to

if [ -n "$1" ]; then
    commit_message="$@"

what do you think about

Informationen
Use markdown syntax , like backticks.
Please post the entire output from your terminal that is related to the bug, and remember to censor your token.

To Reproduce
Steps to reproduce the behavior. Really, step by step. How you downloaded the script, how you installed it, how and when do you edit the .env file, mention whether this file was subsequently changed again, etc. Step by step:

Steps are mentioned in dw-0/kiauh#425
The screenshot with the macro is a little bit wrong and the parameter should be placed within quotation marks.
But then only the first word is the commit message.

Screenshots
If applicable, add screenshots to help explain your problem.

Additional context
Add any other context about the problem here.

authentication failing

Hi I'm trying to set this up following the wiki.
I'm running into authentication issues. When following the wiki, the configuring the token isn't mentioned until the configuration section. So when doing the first push, it asks me to authenticate, and it does so by asking for my GitHub username and password, which I then provide. However it then tells me authentication via password is no longer possible since 2021 or so.

from the configuration wiki page, it seems as if authentication should be handles by the .env file. However, that one does not exist for me :

pi@mainsail:~/klipper-backup $ ls -la /home/pi/klipper-backup
total 36
drwxr-xr-x  3 pi pi 4096 Jun  5 18:16 .
drwxr-xr-x 17 pi pi 4096 Jun  5 18:15 ..
-rw-r--r--  1 pi pi  908 Jun  5 18:15 .env.example
drwxr-xr-x  8 pi pi 4096 Jun  5 18:16 .git
-rw-r--r--  1 pi pi   17 Jun  5 18:15 .gitignore
-rwxr-xr-x  1 pi pi 2165 Jun  5 18:15 install.sh
-rw-r--r--  1 pi pi  181 Jun  5 18:15 README.md
-rwxr-xr-x  1 pi pi 1254 Jun  5 18:15 script.sh
-rw-r--r--  1 pi pi    5 Jun  5 18:15 version

However, I don't have an .env variable to edit. Also I must admit that I'm not very familiar with linux, so creating files and adding lines to files from the command line is not something that I know how to do without line by line instruction (sorry for that..).

Unable to push backup

I followed the installation instructions and it pushed to git once but on every subsequent push I get this error:

`Klipper-backup is up to date

Skipping symbolic link: printer_data/config/K-ShakeTune
Skipping symbolic link: printer_data/config/mainsail.cfg
Skipping symbolic link: printer_data/config/print_area_bed_mesh.cfg
Skipping file: printer_data/config/printer-20240121_185359.cfg
Skipping symbolic link: printer_data/config/timelapse.cfg
New branch in .env detected, rename to main branch
fatal: Invalid branch name: 'HEAD'
interactive rebase in progress; onto 5082fce
Last command done (1 command done):
pick 786037a New backup from 01-23-24
No commands remaining.
You are currently editing a commit while rebasing branch 'main' on '5082fce'.
(use "git commit --amend" to amend the current commit)
(use "git rebase --continue" once you are satisfied with your changes)

nothing to commit, working tree clean
From https://[REDACTED]@github.com/[REDACTED].git
From https://github.com/[REDACTED]

  • branch main -> FETCH_HEAD
    fatal: It seems that there is already a rebase-merge directory, and
    I wonder if you are in the middle of another rebase. If that is the
    case, please try
    git rebase (--continue | --abort | --skip)
    If that is not the case, please
    rm -fr ".git/rebase-merge"
    and run me again. I am stopping in case you still have something
    valuable there.

Branch 'main' set up to track remote branch 'main' from 'origin'.
Everything up-to-date`

None of the commends suggested in the error message appear to do anything. The rebase commands give the response: "fatal: No rebase in progress?".

[Feature request]: Add support for selfhosted git

Is your feature request related to a problem? Please describe.

I have a selfhosted Gitea instance. Instead of backing up to github, I would like to backup to my gitea instance.

Describe the solution you'd like

After doing some testing with the script, the only thing that need to be changed is the github.com domain here:
https://github.com/Staubgeborener/klipper-backup/blob/main/script.sh#L57
and here:
https://github.com/Staubgeborener/klipper-backup/blob/main/script.sh#L62

If you could also change this into a variable which defaults to github.com this should be easily integratable.

Describe alternatives you've considered

...

Additional information

No response

Backing up symbolic links

I got everything installed tonight and it went well. I'm liking having an easy backup after a scare this weekend when I thought I lost all of my configs I've been tweaking for the past month.

I noticed in the logs that it is skipping symbolic links which results in my printer_data/config/KAMP folder, mainsail.cfg and timelapse.cfg not being backed up. Is there a way to include these in the .env so they'll be backed up properly? I included the printer_data/config/KAMP folder specifically in the .env but it still skips the folder because it's a symbolic link.

My moonraker also shows the "Dirty" warning but it sounds like this should have been resolved. Not sure what to check to see if I missed a step on this part.

Thank you for the hard work put in to make this so easy for those of us who aren't sure where to start with backing up klipper easily.

cp: unrecognized option '--parents'

Code of Conduct

  • I promise that i have used markdown syntax to make the code more readable which helps to fix the problem

What happened

Error

cp: unrecognized option '--parents'
BusyBox v1.36.1 (2024-02-24 17:59:02 UTC) multi-call binary.

Usage: cp [-arPLHpfinlsTu] SOURCE DEST
or: cp [-arPLHpfinlsu] SOURCE... { -t DIRECTORY | DIRECTORY }

Copy SOURCEs to DEST

	-a	Same as -dpR
	-R,-r	Recurse
	-d,-P	Preserve symlinks (default if -R)
	-L	Follow all symlinks
	-H	Follow symlinks on command line
	-p	Preserve file attributes if possible
	-f	Overwrite
	-i	Prompt before overwrite
	-n	Don't overwrite
	-l,-s	Create (sym)links
	-T	Refuse to copy if DEST is a directory
	-t DIR	Copy all SOURCEs into DIR
	-u	Copy only newer files

during execution of ./klipper-backup/script.sh script

What did you expect to happen

Successful backup.

How to reproduce

  • Printer Ender 3 V3 KE.
  • Install bash GNU bash, version 5.2.15(1)-release (mipsel-openwrt-linux-gnu). installed from https://github.com/Entware/Entware repository
  • BusyBox v1.36.1 (2024-02-24 17:59:02 UTC) multi-call binary. installed from https://github.com/Entware/Entware repository
  • add soft link ln -s /usr/data/printer_data/ /root/printer_data
  • Executed backup script

Additional information

No response

Custom README.md

How can I add a custom readme? The current script always creates a new readme which overrides any changes.

[Bug]: Bus error

What happened

Whe I try to clone the repository, I get the message "Bus error"

What did you expect to happen

It should start the download a copy of repository.

How to reproduce

In terminal I just type:

git clone https://github.com/Staubgeborener/klipper-backup.git && chmod +x ./klipper-backup/script.sh && cp ./klipper-backup/.env.example ./klipper-backup/.env

Additional information

No response

commenting out paths in .env not working

script.sh is also working on pathes in .env, which are commented out with a #.
I would prefer to be able to comment out lines by adding a # at the beginning.

I believe, you could achieve this by changing script.sh:24 to

done < <(grep -v '^#' "$parent_path"/.env | grep 'path_' | sed 's/^.*=//')

changes made to .env file don't seem to get applied?

After following the instructions, everything worked fine. I wanted to change what repository it was going to. I changed that in the .env file but the command seems to still be using the original repository even though the .env no longer show it. I've tried removing the entire "klipper-backup" folder and all it's contents, starting over and reinstalling but somehow it still only runs what was originally in the .env the first time it ran.

Simple way to change the service-name, listed in Mainsail?

Is your feature request related to a problem? Please describe.

I was not able to find the definition of Klipper-backup-filewatch. Where does this string originate from? I want to change it to Auto-Backup for sake of simplicity (and my ocd😅).

image

[Bug]: Script asks for password

What happened

I'm sure I'm doing something dumb, but the script kept asking for a password (3 times) then gives "remote: Repository not found" followed by "fatal: Authentication failed for 'https://github.com/stephenmott/hictop-klipper2.git/'".

What did you expect to happen

Expected the script to not ask for passwords

How to reproduce

I'm not sure..

Additional information

The repo does exist and the password I'm using is the access token and if I go into the config_backuo folder and do a "git remote remove origin", "git remote add origin ..." and "git remote set-url origin ..." with the correct URL, followed by "git push -u origin main" it works fine..?

Then as soon as I run the script again it removes the token from the origin url, then asks for a password again and fails..?

The really odd thing is I'm doing this on 4 Pi's, (3 x Pi 4B & 1 x Pi 5B), the first one worked fine, no problem at all, the second and third gave this issue, but after I cleared git credentials and started again, they eventually worked (nor really sure why), one with a correct origin url, then other one wrong, missing the token. The fourth one just refuses to work no matter what I try.

Not sure if it makes any difference but the one that won't work is the Pi 5B.

Error when Uploading - fatal: not a git repository

Code of Conduct

  • I promise that i have used markdown syntax to make the code more readable which helps to fix the problem

What happened

Not the best with GitHub - sorry.
I installed it following the linked video and got the following errormessage when executing the script.sh/ the Macro.

Klipper-backup is up to date
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
Branch: main in .env does not match the currently checked out branch of: .
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not in a git directory
fatal: not in a git directory
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
Skipping symbolic link: printer_data/config/KAMP
Skipping symbolic link: printer_data/config/mainsail.cfg
Skipping file: printer_data/config/printer-20240102_101142.cfg
Skipping file: printer_data/config/printer-20240112_131407.cfg
Skipping file: printer_data/config/printer-20240226_085630.cfg
Skipping file: printer_data/config/printer-20240226_154211.cfg
Skipping symbolic link: printer_data/config/timelapse.cfg
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: No remote configured to list refs from.
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git

What did you expect to happen

Upload to GitHub

How to reproduce

Don't Know :-(

Additional information

"Klipper-backup is not up to date" Message when running from Mainsail

When I run the macro to execute the Klipper-backup script from Mainsail I am getting a message that Klipper-backup is not up to date. However if I run the script from the terminal it states that it is up to date. I am also using Mainsail update manager to update the script and I am currently running 1.1.0-0-g713d4cfe.

Screenshot 2024-01-18 at 8 18 36 PM Screenshot 2024-01-18 at 8 18 24 PM Screenshot 2024-01-18 at 8 18 02 PM

[Bug]:

What happened

Failure to launch Backup on file changes

What did you expect to happen

It to backup on change but the service wouldn't start

How to reproduce

Use the current code

Additional information

This
inotifywait -mrP -e close_write -e move -e delete --exclude "$exclude_pattern" $watchlist |
should be
inotifywait -mr -e close_write -e move -e delete --exclude "$exclude_pattern" $watchlist |
in klipper-backup-filewatch.service

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.