Skip to content

Configuration

Note

This section shows how to customize Klipper-Backup according to your needs. Certain things like adding the token are already queried by the installation script and automatically inserted if necessary!

.env

Now you need your GitHub token.

  1. Open the .env file inside your repository (for example with vi, vim or nano)
  2. Copy the new token into the .env file at github_token
  3. Add your username in github_username
  4. Change the github_repository to your backup repository name in GitHub (which was called repository-name)

Optional Paramaters

  1. commit_username="" You can change the commit username for the commit history here, for example commit_username="backup user", if it is left empty, the script will use whoami for the current user.
  2. commit_email="" You can change the commit email for the commit history here, if it is left empty the script will use whoami@hostname --long-unique_id. The unique_id is generated by hashing the unique mac address of the system.
  3. allow_empty_commits="" You can choose whether you want to push empty commits or not (this serves to permanently check whether the service is running correctly in the background), for example allow_empty_commits="false". The value can be true or false (default value if nothing is defined: true).
  4. git_protocol="" You can use the values http or https here (default value: https). This enables, for example, the local use of git if https is not supported.
  5. git_host="". If you are using a different host ex.) gitea, bitbucket, devops, etc... you can add git_host="" to .env, for example git_host="bitbucket.org". Be sure to read the requirements for how to push changes to your host ex.) bitbucket requires a specific commit email and token format to push commits.

    Important Note

    When using a host other than github.com you may run into errors or issues that we cannot currently support. If you do find a resolution feel free to create a pull request or feature request

Adjust the remaining paths in the .env file where your files are located, or add even more file. All files defined here (note the pattern! which is explained inside the .env file) are considered in the backup.

Basically, you can break it down to the following three things:

Back up a whole directories instead of single files:

backupPaths=( \
"printer_data/config/*" \
)

Back up a single file instead a whole directory:

backupPaths=( \
"printer_data/config/printer.cfg" \
)

Back up directories and single files whatever you feel like:

backupPaths=( \
"printer_data/config/my-files/*" \
"printer_data/config/my-other-files/*" \
"printer_data/config/single-file_a.cfg" \
"printer_data/config/another-directory/single-file_b.cfg" \
)

.gitignore (do not upload certain files)

To edit the .gitignore file, which is responsible for preventing certain files from being uploaded, you have to name the corresponding files in the .env file. This is important because you do not want to have sensitive data like passwords, tokens, etc. in a public backup. This also means that this file prevents your token from being revoked. By default, the .env file and the secrets.conf are included in the .gitignore and can be extended accordingly. Basically it's an Array of strings in .gitignore pattern git format. New additions must be enclosed in double quotes and should follow the pattern format as noted in the mentioned link:

exclude=( \
"*.swp" \
"*.tmp" \
"printer-[0-9]*_[0-9]*.cfg" \
"*.bak" \
"*.bkp" \
"*.csv" \
"*.zip" \
)

Create own README.md

If there is a need to adapt the README.md files, this can be done at any time. To do this, the script must be run at least once, after which the README.md can be edited manually in the ~/config_backup folder. This is then taken into account during the next upload and adjusted accordingly.

How can I edit files in terminal?

So let's say you want to use nano as your editor of choice (you can use whatever editor you want, for example vi, nvim, emacs, etc) to edit the .env file with your personal information:

  1. Move into the klipper-backup directory: cd ~/klipper-backup
  2. Check if there is a hidden .env file inside this directory: ls -la
  3. Edit .env content with nano: nano .env
  4. Move with your arrow keys ↑ ← ↓ → to the important lines and copy/paste the important content inside (often the right mouse button is used to paste in ssh terminals)
  5. Save content and exit nano with Ctrl+x -> (Y)ES -> [Enter]

A small nano YouTube tutorial can be found here.

Important Note

In case you get an error message like -sh: nano: not found you should install nano: sudo apt install nano

If you have installed Klipper-Backup with the install.sh script, you should be finished with everything at this point. Reminder: You can install features at anytime automatically by running install.sh again, so there is no need to do it manually!

In case you want to do it manually for some reason: Next: The update section