backup-docker-to-local 1.0.0__py3-none-any.whl
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.
- backup_docker_to_local-1.0.0.dist-info/METADATA +230 -0
- backup_docker_to_local-1.0.0.dist-info/RECORD +25 -0
- backup_docker_to_local-1.0.0.dist-info/WHEEL +5 -0
- backup_docker_to_local-1.0.0.dist-info/entry_points.txt +4 -0
- backup_docker_to_local-1.0.0.dist-info/licenses/LICENSE +661 -0
- backup_docker_to_local-1.0.0.dist-info/top_level.txt +1 -0
- baudolo/__init__.py +0 -0
- baudolo/backup/__init__.py +1 -0
- baudolo/backup/__main__.py +9 -0
- baudolo/backup/app.py +183 -0
- baudolo/backup/cli.py +93 -0
- baudolo/backup/compose.py +31 -0
- baudolo/backup/db.py +73 -0
- baudolo/backup/docker.py +43 -0
- baudolo/backup/shell.py +26 -0
- baudolo/backup/volume.py +42 -0
- baudolo/restore/__init__.py +1 -0
- baudolo/restore/__main__.py +144 -0
- baudolo/restore/db/__init__.py +1 -0
- baudolo/restore/db/mariadb.py +89 -0
- baudolo/restore/db/postgres.py +53 -0
- baudolo/restore/files.py +37 -0
- baudolo/restore/paths.py +29 -0
- baudolo/restore/run.py +89 -0
- baudolo/seed/__main__.py +50 -0
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: backup-docker-to-local
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Backup Docker volumes to local with rsync and optional DB dumps.
|
|
5
|
+
Author: Kevin Veen-Birkenbach
|
|
6
|
+
License: AGPL-3.0-or-later
|
|
7
|
+
Requires-Python: >=3.9
|
|
8
|
+
Description-Content-Type: text/markdown
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Requires-Dist: pandas
|
|
11
|
+
Requires-Dist: dirval
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# baudolo โ Deterministic Backup & Restore for Docker Volumes ๐ฆ๐
|
|
15
|
+
[](https://github.com/sponsors/kevinveenbirkenbach) [](https://www.patreon.com/c/kevinveenbirkenbach) [](https://buymeacoffee.com/kevinveenbirkenbach) [](https://s.veen.world/paypaldonate) [](https://www.gnu.org/licenses/agpl-3.0) [](https://www.docker.com) [](https://www.python.org) [](https://github.com/kevinveenbirkenbach/backup-docker-to-local/stargazers)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
`baudolo` is a backup and restore system for Docker volumes with
|
|
19
|
+
**mandatory file backups** and **explicit, deterministic database dumps**.
|
|
20
|
+
It is designed for environments with many Docker services where:
|
|
21
|
+
- file-level backups must always exist
|
|
22
|
+
- database dumps must be intentional, predictable, and auditable
|
|
23
|
+
|
|
24
|
+
## โจ Key Features
|
|
25
|
+
|
|
26
|
+
- ๐ฆ Incremental Docker volume backups using `rsync --link-dest`
|
|
27
|
+
- ๐ Optional SQL dumps for:
|
|
28
|
+
- PostgreSQL
|
|
29
|
+
- MariaDB / MySQL
|
|
30
|
+
- ๐ฑ Explicit database definition for SQL backups (no auto-discovery)
|
|
31
|
+
- ๐งพ Backup integrity stamping via `dirval` (Python API)
|
|
32
|
+
- โธ Automatic container stop/start when required for consistency
|
|
33
|
+
- ๐ซ Whitelisting of containers that do not require stopping
|
|
34
|
+
- โป๏ธ Modular, maintainable Python architecture
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
## ๐ง Core Concept (Important!)
|
|
38
|
+
|
|
39
|
+
`baudolo` **separates file backups from database dumps**.
|
|
40
|
+
|
|
41
|
+
- **Docker volumes are always backed up at file level**
|
|
42
|
+
- **SQL dumps are created only for explicitly defined databases**
|
|
43
|
+
|
|
44
|
+
This results in the following behavior:
|
|
45
|
+
|
|
46
|
+
| Database defined | File backup | SQL dump |
|
|
47
|
+
|------------------|-------------|----------|
|
|
48
|
+
| No | โ yes | โ no |
|
|
49
|
+
| Yes | โ yes | โ yes |
|
|
50
|
+
|
|
51
|
+
## ๐ Backup Layout
|
|
52
|
+
|
|
53
|
+
Backups are stored in a deterministic, fully nested structure:
|
|
54
|
+
|
|
55
|
+
```text
|
|
56
|
+
<backups-dir>/
|
|
57
|
+
โโโ <machine-hash>/
|
|
58
|
+
โโโ <repo-name>/
|
|
59
|
+
โโโ <timestamp>/
|
|
60
|
+
โโโ <volume-name>/
|
|
61
|
+
โโโ files/
|
|
62
|
+
โโโ sql/
|
|
63
|
+
โโโ <database>.backup.sql
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Meaning of each level
|
|
67
|
+
|
|
68
|
+
* `<machine-hash>`
|
|
69
|
+
SHA256 hash of `/etc/machine-id` (host separation)
|
|
70
|
+
|
|
71
|
+
* `<repo-name>`
|
|
72
|
+
Logical backup namespace (project / stack)
|
|
73
|
+
|
|
74
|
+
* `<timestamp>`
|
|
75
|
+
Backup generation (`YYYYMMDDHHMMSS`)
|
|
76
|
+
|
|
77
|
+
* `<volume-name>`
|
|
78
|
+
Docker volume name
|
|
79
|
+
|
|
80
|
+
* `files/`
|
|
81
|
+
Incremental file backup (rsync)
|
|
82
|
+
|
|
83
|
+
* `sql/`
|
|
84
|
+
Optional SQL dumps (only for defined databases)
|
|
85
|
+
|
|
86
|
+
## ๐ Installation
|
|
87
|
+
|
|
88
|
+
### Local (editable install)
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
python3 -m venv .venv
|
|
92
|
+
source .venv/bin/activate
|
|
93
|
+
pip install -e .
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## ๐ฑ Database Definition (SQL Backup Scope)
|
|
97
|
+
|
|
98
|
+
### How SQL backups are defined
|
|
99
|
+
|
|
100
|
+
`baudolo` creates SQL dumps **only** for databases that are **explicitly defined**
|
|
101
|
+
via configuration (e.g. a databases definition file or seeding step).
|
|
102
|
+
|
|
103
|
+
If a database is **not defined**:
|
|
104
|
+
|
|
105
|
+
* its Docker volume is still backed up (files)
|
|
106
|
+
* **no SQL dump is created**
|
|
107
|
+
|
|
108
|
+
> No database definition โ file backup only
|
|
109
|
+
> Database definition present โ file backup + SQL dump
|
|
110
|
+
|
|
111
|
+
### Why explicit definition?
|
|
112
|
+
|
|
113
|
+
`baudolo` does **not** inspect running containers to guess databases.
|
|
114
|
+
|
|
115
|
+
Databases must be explicitly defined to guarantee:
|
|
116
|
+
|
|
117
|
+
* deterministic backups
|
|
118
|
+
* predictable restore behavior
|
|
119
|
+
* reproducible environments
|
|
120
|
+
* zero accidental production data exposure
|
|
121
|
+
|
|
122
|
+
### Required database metadata
|
|
123
|
+
|
|
124
|
+
Each database definition provides:
|
|
125
|
+
|
|
126
|
+
* database instance (container or logical instance)
|
|
127
|
+
* database name
|
|
128
|
+
* database user
|
|
129
|
+
* database password
|
|
130
|
+
|
|
131
|
+
This information is used by `baudolo` to execute
|
|
132
|
+
`pg_dump`, `pg_dumpall`, or `mariadb-dump`.
|
|
133
|
+
|
|
134
|
+
## ๐พ Running a Backup
|
|
135
|
+
|
|
136
|
+
```bash
|
|
137
|
+
baudolo \
|
|
138
|
+
--compose-dir /srv/docker \
|
|
139
|
+
--databases-csv /etc/baudolo/databases.csv \
|
|
140
|
+
--database-containers central-postgres central-mariadb \
|
|
141
|
+
--images-no-stop-required alpine postgres mariadb mysql \
|
|
142
|
+
--images-no-backup-required redis busybox
|
|
143
|
+
```
|
|
144
|
+
|
|
145
|
+
### Common Backup Flags
|
|
146
|
+
|
|
147
|
+
| Flag | Description |
|
|
148
|
+
| --------------- | ------------------------------------------- |
|
|
149
|
+
| `--everything` | Always stop containers and re-run rsync |
|
|
150
|
+
| `--dump-only` | Only create SQL dumps, skip file backups |
|
|
151
|
+
| `--shutdown` | Do not restart containers after backup |
|
|
152
|
+
| `--backups-dir` | Backup root directory (default: `/Backups`) |
|
|
153
|
+
| `--repo-name` | Backup namespace under machine hash |
|
|
154
|
+
|
|
155
|
+
## โป๏ธ Restore Operations
|
|
156
|
+
|
|
157
|
+
### Restore Volume Files
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
baudolo-restore files \
|
|
161
|
+
my-volume \
|
|
162
|
+
<machine-hash> \
|
|
163
|
+
<version> \
|
|
164
|
+
--backups-dir /Backups \
|
|
165
|
+
--repo-name my-repo
|
|
166
|
+
```
|
|
167
|
+
|
|
168
|
+
Restore into a **different target volume**:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
baudolo-restore files \
|
|
172
|
+
target-volume \
|
|
173
|
+
<machine-hash> \
|
|
174
|
+
<version> \
|
|
175
|
+
--source-volume source-volume
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### Restore PostgreSQL
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
baudolo-restore postgres \
|
|
182
|
+
my-volume \
|
|
183
|
+
<machine-hash> \
|
|
184
|
+
<version> \
|
|
185
|
+
--container postgres \
|
|
186
|
+
--db-name appdb \
|
|
187
|
+
--db-password secret \
|
|
188
|
+
--empty
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
### Restore MariaDB / MySQL
|
|
192
|
+
|
|
193
|
+
```bash
|
|
194
|
+
baudolo-restore mariadb \
|
|
195
|
+
my-volume \
|
|
196
|
+
<machine-hash> \
|
|
197
|
+
<version> \
|
|
198
|
+
--container mariadb \
|
|
199
|
+
--db-name shopdb \
|
|
200
|
+
--db-password secret \
|
|
201
|
+
--empty
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
> `baudolo` automatically detects whether `mariadb` or `mysql`
|
|
205
|
+
> is available inside the container
|
|
206
|
+
|
|
207
|
+
## ๐ Backup Scheme
|
|
208
|
+
|
|
209
|
+
The backup mechanism uses incremental backups with rsync and stamps directories with a unique hash. For more details on the backup scheme, check out [this blog post](https://blog.veen.world/blog/2020/12/26/how-i-backup-dedicated-root-servers/).
|
|
210
|
+

|
|
211
|
+
|
|
212
|
+
## ๐จโ๐ป Author
|
|
213
|
+
|
|
214
|
+
**Kevin Veen-Birkenbach**
|
|
215
|
+
- ๐ง [kevin@veen.world](mailto:kevin@veen.world)
|
|
216
|
+
- ๐ [https://www.veen.world/](https://www.veen.world/)
|
|
217
|
+
|
|
218
|
+
## ๐ License
|
|
219
|
+
|
|
220
|
+
This project is licensed under the **GNU Affero General Public License v3.0**. See the [LICENSE](./LICENSE) file for details.
|
|
221
|
+
|
|
222
|
+
## ๐ More Information
|
|
223
|
+
|
|
224
|
+
- [Docker Volumes Documentation](https://docs.docker.com/storage/volumes/)
|
|
225
|
+
- [Docker Backup Volumes Blog](https://blog.ssdnodes.com/blog/docker-backup-volumes/)
|
|
226
|
+
- [Backup Strategies](https://en.wikipedia.org/wiki/Incremental_backup#Incremental)
|
|
227
|
+
|
|
228
|
+
---
|
|
229
|
+
|
|
230
|
+
Happy Backing Up! ๐๐
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
backup_docker_to_local-1.0.0.dist-info/licenses/LICENSE,sha256=hIahDEOTzuHCU5J2nd07LWwkLW7Hko4UFO__ffsvB-8,34523
|
|
2
|
+
baudolo/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
|
+
baudolo/backup/__init__.py,sha256=5BfF8JBXB2j6sAptcmswtbjlajNWxOho6_CjwIamO7k,30
|
|
4
|
+
baudolo/backup/__main__.py,sha256=118gZ0wij9_PAtR-jlG7LizrhrxwhHlAcAPW1eFeJtU,140
|
|
5
|
+
baudolo/backup/app.py,sha256=eZJ0Y1LYZ_NiYw-nzb-h7-x-5AbZFsCjqsP127Mfy-I,5796
|
|
6
|
+
baudolo/backup/cli.py,sha256=u-lQyfbPPiZOnOQ8ugS5yeXHfRVLBOGOw40iOUsOd5s,2619
|
|
7
|
+
baudolo/backup/compose.py,sha256=LKwMzfroKML0miZqJzzhXN3SMm07Ry_85l3p4B0cqeo,1130
|
|
8
|
+
baudolo/backup/db.py,sha256=hNL08pV0osNrOBD3k_EhP8boawRWTc7QlpIPEKitD-E,2402
|
|
9
|
+
baudolo/backup/docker.py,sha256=QxP8C-O7glWrOvZnhELI4-8E2vz_xXEy0CM8QeW8u3k,1342
|
|
10
|
+
baudolo/backup/shell.py,sha256=guMHWcRb0Qlrz79gqFqmJLXVQK8cJEvNkhkMe5Tpgwc,738
|
|
11
|
+
baudolo/backup/volume.py,sha256=_bz-G0HLdDETnWuiAB-geb5xbEaLLsxs9uPFK0lsADc,1449
|
|
12
|
+
baudolo/restore/__init__.py,sha256=qGPo54bmX0D1TRuP22sTQXhpOOwTa8BheEq8aWKsWOk,18
|
|
13
|
+
baudolo/restore/__main__.py,sha256=c0u0YS7xqLRxn9gsvXvorlU8jbs4LlSDxU7JiBAtdIk,5083
|
|
14
|
+
baudolo/restore/files.py,sha256=vV2M60i3-9rwLFV1Kb1Fc_m1SXYYOFUEPQKCMnlOpo4,1031
|
|
15
|
+
baudolo/restore/paths.py,sha256=fcM-39loVXsi-0qgG2FxFmYh3R748Ss5CJqnZinKcNE,708
|
|
16
|
+
baudolo/restore/run.py,sha256=rai5F27D6F8RRnFMyjcEGiHBAlVXtMOJoazs6zkLSC0,2302
|
|
17
|
+
baudolo/restore/db/__init__.py,sha256=9NfiJvVx-sIJfLuZYnOHGjunpbFyqGZSqISFgLTcP5o,58
|
|
18
|
+
baudolo/restore/db/mariadb.py,sha256=0sk6eJiDDr-knIEQyqQIHNtRt7AQrqRlOlnOijVVLno,2516
|
|
19
|
+
baudolo/restore/db/postgres.py,sha256=_NIlcxdpcQIUZ8SNBWfWIaH1oGIkmZy9emFMgjGznhk,1446
|
|
20
|
+
baudolo/seed/__main__.py,sha256=yVWzODjWLBtRVNTOrZNZTV8pBNm6LGWGNKAe7lrJVa8,1874
|
|
21
|
+
backup_docker_to_local-1.0.0.dist-info/METADATA,sha256=XsXf4_FpX_PECc1oJKU4rKgkVsjWuzPuxjz_a5JVPLM,7116
|
|
22
|
+
backup_docker_to_local-1.0.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
23
|
+
backup_docker_to_local-1.0.0.dist-info/entry_points.txt,sha256=92f5jPSjW__9-u5gzwmWkdiHKt4ysEFCVmwMtorQCv4,147
|
|
24
|
+
backup_docker_to_local-1.0.0.dist-info/top_level.txt,sha256=y_5iNpF7EdLzqWWXIDfcTJpqijyy2hvrYgNiJXrN4r4,8
|
|
25
|
+
backup_docker_to_local-1.0.0.dist-info/RECORD,,
|