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!
Warning
Only edit the content of the .env
file with the following parameters, never edit script.sh
manually!
Minimalistic .env overview (mandatory parameters!)¶
Now you need your GitHub token. This should already be done by the installation script. The following steps are for implementing the token, username and repository name. These three parameters are mandatory.
- Open the
.env
file inside your repository (for example withvi
,vim
ornano
) - Copy the new token into the
.env
file atgithub_token
- Add your username in
github_username
- Change the
github_repository
to your backup repository name in GitHub (which was calledrepository-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
output for the current user.
Parameter | Possible values | Default value | Example |
---|---|---|---|
commit_username |
anything | whoami output |
commit_username="backup 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 --short-unique_id
. The unique_id is generated by hashing the output of date +%s%N
(current unix timestamp in nanoseconds).
Parameter | Possible values | Default value | Example |
---|---|---|---|
commit_email |
anything | whoami@hostname --short-unique_id output |
commit_email="backup@hostname" |
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). The value can be true
or false
(default value if nothing is defined: true
).
Parameter | Possible values | Default value | Example |
---|---|---|---|
allow_empty_commits |
true , false |
true |
allow_empty_commits="false" |
4. git_protocol¶
You can use the values http
, https
or ssh
here (default value: https
). This enables, for example, the local use of git if https
is not supported.
Parameter | Possible values | Default value | Example |
---|---|---|---|
git_protocol |
https , http , ssh |
https |
git_protocol="http" |
5. git_host¶
If you are using a different host ex.) gitea, bitbucket, devops, etc... you can add git_host
with the corresponding entity 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. If you have deployed the git instance locally and assigned a port, you can also pass it directly here, for example gitea:222
. 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.
Parameter | Possible values | Default value | Example |
---|---|---|---|
git_host |
gitea , bitbucket , devops , * |
github.com |
git_host="bitbucket.com" |
git_host="localhost:222" |
* List is not complete, there are numerous other (unknown) supported hosters
6. ssh_user¶
If you want to push the backup via ssh and have assigned an individual ssh user, you can adjust it here. This is particularly relevant if you have deployed a git instance locally.
Parameter | Possible values | Default value | Example |
---|---|---|---|
ssh_user |
anything | git |
ssh_user="sshuser" |
Paths¶
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:
Back up a single file instead a whole directory:
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:
- Move into the
klipper-backup
directory:cd ~/klipper-backup
- Check if there is a hidden
.env
file inside this directory:ls -la
- Edit
.env
content withnano
:nano .env
- 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)
- 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