kistn 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
kistn-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,119 @@
1
+ Metadata-Version: 2.3
2
+ Name: kistn
3
+ Version: 0.1.0
4
+ Summary: A lightweight backup solution using BorgBackup and a Hetzner storage box.
5
+ Author: Kangonaut
6
+ Author-email: Kangonaut <120662571+Kangonaut@users.noreply.github.com>
7
+ Requires-Dist: packaging>=26.3
8
+ Requires-Dist: platformdirs>=4.11.3
9
+ Requires-Dist: pydantic>=2.13.4
10
+ Requires-Dist: pyyaml>=6.0.3
11
+ Requires-Dist: questionary>=2.1.1
12
+ Requires-Dist: rich>=15.0.0
13
+ Requires-Dist: typer>=0.27.1
14
+ Requires-Python: >=3.14
15
+ Description-Content-Type: text/markdown
16
+
17
+ <div align="center">
18
+
19
+ # 📦 `kistn`
20
+
21
+ [![license](https://img.shields.io/badge/license-Apache%20License%202.0-blue)](https://github.com/Kangonaut/kistn/blob/main/LICENSE)
22
+
23
+ </div>
24
+
25
+ `kistn` is lightweight backup solution using [BorgBackup](https://www.borgbackup.org/), [Borgmatic](https://torsion.org/borgmatic/) and a [Hetzner storage box](https://www.hetzner.com/storage/storage-box/).
26
+
27
+ ### Why does this project exist?
28
+
29
+ I am very forgetful. I've been using Borgmatic to run my backups for a while now, but every time I want to configure a new backup, I need to look up how to do it again. Sure, I could simply write a guide for myself or ask some AI, but I thought: Why not create a small CLI tool that does everything for me. This also solves my second problem: I always forget to actually do the backups. So why not build a tool that guides you through the setup and also reminds you to do your backups, or even does the backups automatically in the background.
30
+
31
+ ### Should I use `kistn`?
32
+
33
+ If you are also forgetful or you don't want to read up on how Borgmatic works, then I think this might be a helpful tool for you. I've tried to make the user experience as simple as possible and to guide the user through the setup process. I hope that this means that it can even be used by people, who are not heavy-terminal users. However, it is a CLI tool, so if you'd rather just click some buttons in a fancy GUI, there are surely better options out there. Anyway, this tool is far from being a mature software, but I think it is still usable. If you encounter any problems, you can open an issue and hope for a reply. Sorry, I'm often busy. :)
34
+
35
+ ### Why should I use a Hetzner storage backup box?
36
+
37
+ There are many other options out there and I'm not saying Hetzner has the best solution. But considering the options I've used so far, it is probably the best and cheapest option I know. `kistn` technically works with any server that is running `borg` and OpenSSH, but it is meant to be used with a Hetzner storage box, because that's what I use. :)
38
+
39
+ ## Getting Started
40
+
41
+ ### 0. Install `uv`
42
+
43
+ `uv` is a really nice Python package manager. It's technically not required to install `kistn`, but if you don't know what you are doing, simply use `uv`. You won't be disappointed.
44
+
45
+ 1. Check if `uv` is already installed: `uv --version`.
46
+ 2. If not, follow the [installation instructions](https://docs.astral.sh/uv/getting-started/installation/) or simply run the following command:
47
+
48
+ ```shell
49
+ curl -LsSf https://astral.sh/uv/install.sh | sh
50
+ ```
51
+
52
+ ### 1. Install `kistn`
53
+
54
+ 1. Install using `uv`: `uv tool install kistn`
55
+
56
+ ### 2. Check Dependencies
57
+
58
+ 1. Run `kistn doctor` to see if your system has all the necessary packages installed.
59
+
60
+ ### 3. (Optional) Add Overdue-Check to Shell Config
61
+
62
+ If you want to get a reminder to do your overdue backups every time you open a new shell session, then follow the instructions below. The reminder will look something like this:
63
+
64
+ ```shell
65
+ âš  WARN: basic: Your last backup was 7 days ago. Run `kistn run basic` to start the backup.
66
+ ```
67
+
68
+ 1. Open your shell config in your favourite editor. If you are using `zsh`, open `~/.zshrc`. If you are using `bash`, open `.bashrc`.
69
+ 2. If you're using `bash` or `zsh`, add the following lines to the very top of your config:
70
+
71
+ ```bash
72
+ # Check for overdue kistn backups
73
+ if [ -f "$HOME/.local/bin/kistn" ]; then
74
+ "$HOME/.local/bin/kistn" check-overdue
75
+ fi
76
+ ```
77
+
78
+ TODO: add instructions for other shells like `fish`
79
+
80
+ ### 4. Setup the Storage Box
81
+
82
+ 1. Go to the [Hetzner Console](https://console.hetzner.com/) and find your storage box.
83
+ 2. Make sure that **SSH Support** and **External Reachability** is enabled.
84
+ 3. Keep the page open to look up the hostname, username and port later.
85
+
86
+ ### 5. Create a Remote Connection
87
+
88
+ 1. Run `kistn remote wizard NAME` and follow the instructions. `NAME` should be a simple name to identify your storage box. It probably makes sense to simply adopt the name that is displayed in the Hetzner Console.
89
+ 2. Run `kistn remote list` to check if the remote connection is ready to use. It should say `ready` in the `State` column.
90
+
91
+ **NOTE:** If the `kistn remote wizard` command fails or you interrupt it, you can continue the setup by simply running the command again.
92
+
93
+ <div align="center">
94
+ <img src="assets/remote-wizard.png" width="640"/>
95
+ </div>
96
+
97
+ ### 6. Create a Backup Profile
98
+
99
+ 1. Run `kistn profile wizard NAME` and follow the instructions. `NAME` should again be a simple name to identify your backup profile, such as `basic`, `documents`, `university`, `photos`, ...
100
+ 2. Make sure you store your paper key at a secure location.
101
+ 3. Run `kistn profile list` to check if the profile is ready. Again, it should say `ready` in the `State` column.
102
+
103
+ **NOTE:** If the `kistn remote profile` command fails or you interrupt it, you can continue the setup by simply running the command again.
104
+
105
+ <div align="center">
106
+ <img src="assets/profile-wizard.png" width="640"/>
107
+ </div>
108
+
109
+ ### 7. Create your first Backup
110
+
111
+ 1. Run your first backup using `kistn run PROFILE-NAME`.
112
+
113
+ ### 8. Check when to do your next Backup
114
+
115
+ 1. Use `kistn status` to see when you did your last backup and when the next backup is due. If you chose a frequency of 7, it should say `in 7 days`.
116
+
117
+ ## License
118
+
119
+ Distributed under the [Apache License 2.0](https://github.com/Kangonaut/kistn/blob/main/LICENSE).
kistn-0.1.0/README.md ADDED
@@ -0,0 +1,103 @@
1
+ <div align="center">
2
+
3
+ # 📦 `kistn`
4
+
5
+ [![license](https://img.shields.io/badge/license-Apache%20License%202.0-blue)](https://github.com/Kangonaut/kistn/blob/main/LICENSE)
6
+
7
+ </div>
8
+
9
+ `kistn` is lightweight backup solution using [BorgBackup](https://www.borgbackup.org/), [Borgmatic](https://torsion.org/borgmatic/) and a [Hetzner storage box](https://www.hetzner.com/storage/storage-box/).
10
+
11
+ ### Why does this project exist?
12
+
13
+ I am very forgetful. I've been using Borgmatic to run my backups for a while now, but every time I want to configure a new backup, I need to look up how to do it again. Sure, I could simply write a guide for myself or ask some AI, but I thought: Why not create a small CLI tool that does everything for me. This also solves my second problem: I always forget to actually do the backups. So why not build a tool that guides you through the setup and also reminds you to do your backups, or even does the backups automatically in the background.
14
+
15
+ ### Should I use `kistn`?
16
+
17
+ If you are also forgetful or you don't want to read up on how Borgmatic works, then I think this might be a helpful tool for you. I've tried to make the user experience as simple as possible and to guide the user through the setup process. I hope that this means that it can even be used by people, who are not heavy-terminal users. However, it is a CLI tool, so if you'd rather just click some buttons in a fancy GUI, there are surely better options out there. Anyway, this tool is far from being a mature software, but I think it is still usable. If you encounter any problems, you can open an issue and hope for a reply. Sorry, I'm often busy. :)
18
+
19
+ ### Why should I use a Hetzner storage backup box?
20
+
21
+ There are many other options out there and I'm not saying Hetzner has the best solution. But considering the options I've used so far, it is probably the best and cheapest option I know. `kistn` technically works with any server that is running `borg` and OpenSSH, but it is meant to be used with a Hetzner storage box, because that's what I use. :)
22
+
23
+ ## Getting Started
24
+
25
+ ### 0. Install `uv`
26
+
27
+ `uv` is a really nice Python package manager. It's technically not required to install `kistn`, but if you don't know what you are doing, simply use `uv`. You won't be disappointed.
28
+
29
+ 1. Check if `uv` is already installed: `uv --version`.
30
+ 2. If not, follow the [installation instructions](https://docs.astral.sh/uv/getting-started/installation/) or simply run the following command:
31
+
32
+ ```shell
33
+ curl -LsSf https://astral.sh/uv/install.sh | sh
34
+ ```
35
+
36
+ ### 1. Install `kistn`
37
+
38
+ 1. Install using `uv`: `uv tool install kistn`
39
+
40
+ ### 2. Check Dependencies
41
+
42
+ 1. Run `kistn doctor` to see if your system has all the necessary packages installed.
43
+
44
+ ### 3. (Optional) Add Overdue-Check to Shell Config
45
+
46
+ If you want to get a reminder to do your overdue backups every time you open a new shell session, then follow the instructions below. The reminder will look something like this:
47
+
48
+ ```shell
49
+ âš  WARN: basic: Your last backup was 7 days ago. Run `kistn run basic` to start the backup.
50
+ ```
51
+
52
+ 1. Open your shell config in your favourite editor. If you are using `zsh`, open `~/.zshrc`. If you are using `bash`, open `.bashrc`.
53
+ 2. If you're using `bash` or `zsh`, add the following lines to the very top of your config:
54
+
55
+ ```bash
56
+ # Check for overdue kistn backups
57
+ if [ -f "$HOME/.local/bin/kistn" ]; then
58
+ "$HOME/.local/bin/kistn" check-overdue
59
+ fi
60
+ ```
61
+
62
+ TODO: add instructions for other shells like `fish`
63
+
64
+ ### 4. Setup the Storage Box
65
+
66
+ 1. Go to the [Hetzner Console](https://console.hetzner.com/) and find your storage box.
67
+ 2. Make sure that **SSH Support** and **External Reachability** is enabled.
68
+ 3. Keep the page open to look up the hostname, username and port later.
69
+
70
+ ### 5. Create a Remote Connection
71
+
72
+ 1. Run `kistn remote wizard NAME` and follow the instructions. `NAME` should be a simple name to identify your storage box. It probably makes sense to simply adopt the name that is displayed in the Hetzner Console.
73
+ 2. Run `kistn remote list` to check if the remote connection is ready to use. It should say `ready` in the `State` column.
74
+
75
+ **NOTE:** If the `kistn remote wizard` command fails or you interrupt it, you can continue the setup by simply running the command again.
76
+
77
+ <div align="center">
78
+ <img src="assets/remote-wizard.png" width="640"/>
79
+ </div>
80
+
81
+ ### 6. Create a Backup Profile
82
+
83
+ 1. Run `kistn profile wizard NAME` and follow the instructions. `NAME` should again be a simple name to identify your backup profile, such as `basic`, `documents`, `university`, `photos`, ...
84
+ 2. Make sure you store your paper key at a secure location.
85
+ 3. Run `kistn profile list` to check if the profile is ready. Again, it should say `ready` in the `State` column.
86
+
87
+ **NOTE:** If the `kistn remote profile` command fails or you interrupt it, you can continue the setup by simply running the command again.
88
+
89
+ <div align="center">
90
+ <img src="assets/profile-wizard.png" width="640"/>
91
+ </div>
92
+
93
+ ### 7. Create your first Backup
94
+
95
+ 1. Run your first backup using `kistn run PROFILE-NAME`.
96
+
97
+ ### 8. Check when to do your next Backup
98
+
99
+ 1. Use `kistn status` to see when you did your last backup and when the next backup is due. If you chose a frequency of 7, it should say `in 7 days`.
100
+
101
+ ## License
102
+
103
+ Distributed under the [Apache License 2.0](https://github.com/Kangonaut/kistn/blob/main/LICENSE).
@@ -0,0 +1,26 @@
1
+ [project]
2
+ name = "kistn"
3
+ version = "0.1.0"
4
+ description = "A lightweight backup solution using BorgBackup and a Hetzner storage box."
5
+ readme = "README.md"
6
+ requires-python = ">=3.14"
7
+ dependencies = [
8
+ "packaging>=26.3",
9
+ "platformdirs>=4.11.3",
10
+ "pydantic>=2.13.4",
11
+ "pyyaml>=6.0.3",
12
+ "questionary>=2.1.1",
13
+ "rich>=15.0.0",
14
+ "typer>=0.27.1",
15
+ ]
16
+
17
+ [[project.authors]]
18
+ name = "Kangonaut"
19
+ email = "120662571+Kangonaut@users.noreply.github.com"
20
+
21
+ [project.scripts]
22
+ kistn = "kistn.main:main"
23
+
24
+ [build-system]
25
+ requires = ["uv_build>=0.12.5,<0.13.0"]
26
+ build-backend = "uv_build"
@@ -0,0 +1,25 @@
1
+ [project]
2
+ name = "kistn"
3
+ version = "0.1.0"
4
+ description = "A lightweight backup solution using BorgBackup and a Hetzner storage box."
5
+ readme = "README.md"
6
+ authors = [
7
+ { name = "Kangonaut", email = "120662571+Kangonaut@users.noreply.github.com" }
8
+ ]
9
+ requires-python = ">=3.14"
10
+ dependencies = [
11
+ "packaging>=26.3",
12
+ "platformdirs>=4.11.3",
13
+ "pydantic>=2.13.4",
14
+ "pyyaml>=6.0.3",
15
+ "questionary>=2.1.1",
16
+ "rich>=15.0.0",
17
+ "typer>=0.27.1",
18
+ ]
19
+
20
+ [project.scripts]
21
+ kistn = "kistn.main:main"
22
+
23
+ [build-system]
24
+ requires = ["uv_build>=0.12.5,<0.13.0"]
25
+ build-backend = "uv_build"
File without changes
@@ -0,0 +1,50 @@
1
+ from pathlib import Path
2
+
3
+ from pydantic import BaseModel, Field
4
+
5
+ from kistn import consts, utils
6
+
7
+
8
+ class BorgmaticRepository(BaseModel):
9
+ path: str
10
+ label: str
11
+
12
+
13
+ class BorgmaticCheck(BaseModel):
14
+ name: str
15
+
16
+
17
+ class BorgmaticConfig(BaseModel):
18
+ source_directories: list[Path]
19
+ exclude_patterns: list[str] = Field(default_factory=list)
20
+ repositories: list[BorgmaticRepository]
21
+
22
+ # storage and encryption
23
+ encryption_passphrase: str
24
+ compression: str
25
+ archive_name_format: str # prefix-{hostname}-{now}
26
+
27
+ # retention policy
28
+ keep_daily: int
29
+ keep_weekly: int
30
+ keep_monthly: int
31
+
32
+ # consistency checks
33
+ checks: list[BorgmaticCheck]
34
+
35
+ @classmethod
36
+ def get_path(cls, name: str) -> Path:
37
+ return consts.BORGMATIC_CONFIG_DIR / f"kistn.{name}"
38
+
39
+ @classmethod
40
+ def load(cls, name: str) -> BorgmaticConfig:
41
+ return utils.io.load_pydantic_from_yaml(BorgmaticConfig, cls.get_path(name))
42
+
43
+ def save(self, name: str):
44
+ # create file with permissions
45
+ path = consts.BORGMATIC_CONFIG_DIR / f"kistn.{name}"
46
+ path.touch(mode=0o600, exist_ok=True)
47
+
48
+ # serialize to yaml
49
+ path.parent.mkdir(parents=True, exist_ok=True)
50
+ utils.io.save_pydantic_to_yaml(self, self.get_path(name))
@@ -0,0 +1 @@
1
+ from . import profile, remote, system