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.
- 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¶
commit_username=""
You can change the commit username for the commit history here, for examplecommit_username="backup user"
, if it is left empty, the script will usewhoami
for the current user.commit_email=""
You can change the commit email for the commit history here, if it is left empty the script will usewhoami@hostname --long-unique_id
. The unique_id is generated by hashing the unique mac address of the system.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 exampleallow_empty_commits="false"
. The value can betrue
orfalse
(default value if nothing is defined:true
).git_protocol=""
You can use the valueshttp
orhttps
here (default value:https
). This enables, for example, the local use of git ifhttps
is not supported.-
git_host=""
. If you are using a different host ex.) gitea, bitbucket, devops, etc... you can addgit_host=""
to.env
, for examplegit_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:
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