Skip to content

Commit c170639

Browse files
committed
DOC: Break some lines for a finer read
1 parent 7d526cd commit c170639

File tree

3 files changed

+44
-28
lines changed

3 files changed

+44
-28
lines changed

.github/scripts/aspell-ignorewords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,4 @@ virii
7979
vqwg
8080
worktree
8181
zsh
82+
vL

README.full.md

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,10 @@ fully **encrypted backups** that are really **easily replicated and synced to th
8484
### Use-cases
8585

8686
* **Zero-knowledge cloud sync and storage**
87-
* Replace or supplement existing **poor complex and proprietary solutions** (like Veeam, Time Machine, Google Photos & Drive, iCloud)
88-
or software programs with **complex and unfamiliar CLI APIs or wide attack surfaces** (Bacula, Borg Backup, restic) ...
87+
* Replace or supplement existing **poor complex and proprietary solutions**
88+
(like Veeam, Time Machine, Google Photos & Drive, iCloud)
89+
or software programs with **complex and unfamiliar CLI APIs or wide attack surfaces**
90+
(Bacula, Borg Backup, restic, git-crypt) ...
8991
* Cloud-based serverless virii
9092
* **Protocol- and PaaS-agnostic** design (AWS to Backblaze B2, GitLab to Gitea). Simply sync (even rsync) a git folder.
9193

@@ -98,7 +100,7 @@ To install everything on a Debian/Ubuntu-based system, run:
98100
sudo apt install gzip git git-lfs openssl gpg
99101

100102
# Download and make available somewhere in path
101-
curl -L https://bit.ly/myba-backup > ~/.local/bin/myba
103+
curl -vL 'https://bit.ly/myba-backup' > ~/.local/bin/myba
102104
export PATH="$HOME/.local/bin:$PATH"
103105

104106
myba help
@@ -150,12 +152,13 @@ The script also acknowledges a few **environment variables** which you can _set_
150152
* `PLAIN_REPO=` The _internal_ directory where myba actually stores both its repositories.
151153
Defaults to `$WORK_TREE/.myba` but can be overriden to somewhere out-of-tree ...
152154
* `PASSWORD=` The password to use for encryption instead of asking / reading from stdin.
153-
* `USE_GPG=` Myba uses `openssl enc` by default, but if you prefer to use GPG for symmetric encryption, set `USE_GPG=1`.
154-
* `KDF_ITERS=` A sufficient number of iterations is used for the encryption key derivation function.
155-
To specify your own value and avoid rainbow table attacks on myba itself, you can customize this value.
156-
If you don't know, just leave it.
157-
* `YES_OVERWRITE=` If set, overwrite existing when restoring/checking out files that already exist in $WORK_TREE.
158-
The default is to ask instead.
155+
* `USE_GPG=` Myba uses `openssl enc` by default, but if you prefer to use GPG even for
156+
symmetric encryption, set `USE_GPG=1`.
157+
* `KDF_ITERS=` A sufficient number of iterations is used for the encryption key derivation
158+
function. To specify your own value and avoid rainbow table attacks on myba itself,
159+
you can customize this value. If you don't know, just leave it.
160+
* `YES_OVERWRITE=` If set, overwrite existing when restoring/checking out files that already
161+
exist in $WORK_TREE. The default is to ask instead.
159162
* `VERBOSE=` More verbose output about what the program is doing.
160163

161164

@@ -167,15 +170,15 @@ export WORK_TREE="$HOME"
167170

168171
myba init
169172
myba add Documents Photos Etc .dotfile
170-
PASSWORD=secret myba commit -m "my precious"
173+
PASSWORD='secret' myba commit -m "my precious"
171174
myba remote add origin "/media/usb/backup"
172175
myba remote add github "git@github.com:user/my-backup.git"
173176
myba push # Push to all configured remotes & free disk space
174177

175178
# Somewhere else, much, much later, avoiding catastrophe ...
176179

177180
export WORK_TREE="$HOME"
178-
PASSWORD=secret myba clone "..." # Clone one of the known remotes
181+
PASSWORD='secret' myba clone "..." # Clone one of the known remotes
179182
myba checkout ".dotfile" # Restore backed up files in a space-efficient manner
180183
```
181184
See [_smoke-test.sh_](https://github.com/kernc/myba/blob/master/smoke-test.sh) file for a more full example & test case!
@@ -185,7 +188,8 @@ Contributing
185188
------------
186189
The project is [hosted on github](https://github.com/kernc/myba/).
187190

188-
The script is considered _mostly_ feature-complete, but there remain bugs and design flaws to be discovered and ironed out,
191+
The script is considered _mostly_ feature-complete, but there remain
192+
bugs and design flaws to be discovered and ironed out,
189193
as well as any TODOs and FIXMEs marked in the source.
190194
**All source code lines are open to discussion.**
191195
Especially appreciated are clear pointers to targets for simplification.
@@ -235,8 +239,9 @@ you find widely-applicable and useful.
235239
<details markdown="1">
236240
<summary>Git isn't optimized for continuously-changing databases and binary files ...</summary>
237241

238-
That is correct. Git saves whole file snapshots and doesn't do any in-file or within-file deduplication,
239-
so it's not well suited to automatic continuous backing up of databases that change often.
242+
That is correct. Git saves whole file snapshots and doesn't do any in-file or within-file
243+
or across-file deduplication, so it's not well suited to automatic continuous backing up
244+
of databases that change often.
240245

241246
However, while git repositories bloat when commiting large binary and media files,
242247
**_myba_ only ever uses sparse-checkout**, keeping overhead disk space use to a minimum.

myba.sh

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
#!/bin/sh
22
# myba - Secure, distributed, encrypted backups based on `sh` shell and `git` (and `openssl enc` or `gpg`)
3-
# FIXME review
43
#
54
# Basically your beloved git, but with underlying two repos:
6-
# - bare, local-only _plain repo_ to track changes upon local, plaintext (and binary) files, set e.g. to your $HOME,
7-
# - _encrypted repo_ that holds the encrypted blobs.
5+
# * bare, local-only _plain repo_ to track changes upon local,
6+
# plaintext (and binary) files, set e.g. to your $HOME,
7+
# * _encrypted repo_ that holds the encrypted blobs.
88
# Only the encrypted repo is ever synced with configured remotes.
99
# Every commit into the plain repo creates a commit in the encrypted repo.
10-
# Commits in the encrypted repo carry base64-encoded encrypted commit metadata of the plain repo.
11-
# In the encrypted repo, there is a dir "manifest" with filename "{plain_repo_commit_hash}" and
12-
# line format: `<enc_path>\t<plain_path>`.
13-
# Encrypted paths are like "abc/def//rest-of-hash" and are _deterministic_,
14-
# dependent upon the plain pathname and chosen password! The multi-level fs hierarchy is for near maximum efficiency of `git sparse-checkout`.
15-
# Encrypted blobs are also encrypted deterministically, based on hash of the plain content and chosen password.
10+
# Commits in the encrypted repo carry base64-encoded encrypted commit metadata
11+
# of the plain repo.
12+
# Additional files `$ENC_REPO/manifest/<plain_repo_commit_hash>` with
13+
# with line format: `<enc_path>\t<plain_path>`.
14+
# Encrypted paths are like "$ENC_REPO/abc/def/rest-of-hash" and are _deterministic_,
15+
# dependent upon the plain pathname and chosen password! The multi-level fs hierarchy
16+
# is for near maximum efficiency of `git sparse-checkout`.
17+
# Encrypted blobs are also encrypted deterministically, based on hash of the plain
18+
# content and chosen password.
1619
#
1720
# This is an expected shell workflow:
1821
#
@@ -196,7 +199,7 @@ cmd_init () {
196199
email="$USER@$(hostname 2>/dev/null || cat /etc/hostname)"
197200
git_plain config user.name "$USER"
198201
git_plain config user.email "$email"
199-
git_plain config status.showUntrackedFiles no # We don't care to see largely untracked $HOME # XXX: remove this!
202+
git_plain config status.showUntrackedFiles no # We don't care to see largely untracked $HOME # XXX: remove this?
200203
git_enc config user.name "$USER"
201204
git_enc config user.email "$email"
202205
# All our files are strictly binary (encrypted)
@@ -260,14 +263,17 @@ cmd_restore () {
260263
git_enc sparse-checkout reapply
261264

262265
# Decrypt and stage files from this commit into temp_dir
263-
plain_commit="$(git_enc show --name-only --pretty=format: "$_enc_commit" -- "manifest/" | cut -d/ -f2)"
266+
plain_commit="$(git_enc show --name-only --pretty=format: "$_enc_commit" -- "manifest/" |
267+
cut -d/ -f2)"
264268
while IFS="$_tab" read -r _enc_path _plain_path; do
265269
WORK_TREE="$temp_dir" _decrypt_file "$_enc_path" "$_plain_path"
266270
WORK_TREE="$temp_dir" git_plain add "$_plain_path"
267271
done < "$PLAIN_REPO/manifest/$plain_commit"
268272

269273
# Commit the changes to the plain repo
270-
_msg="$(git_enc show -s --format='%B' "$_enc_commit" | _decrypt "" $_armor_flags | gzip -dc)"
274+
_msg="$(git_enc show -s --format='%B' "$_enc_commit" |
275+
_decrypt "" $_armor_flags |
276+
gzip -dc)"
271277
_date="$(git_enc show -s --format='%ai' "$_enc_commit")"
272278
_author="$(git_enc show -s --format='%an <%ae>' "$_enc_commit")"
273279
if ! WORK_TREE="$temp_dir" git_plain diff --staged --quiet; then
@@ -314,12 +320,16 @@ cmd_commit () {
314320
fi
315321

316322
# Stage new manifest
317-
gzip -c2 "$PLAIN_REPO/$manifest_path" | _encrypt "" > "$ENC_REPO/$manifest_path"
323+
gzip -c2 "$PLAIN_REPO/$manifest_path" |
324+
_encrypt "" > "$ENC_REPO/$manifest_path"
318325
git_enc add --sparse "$manifest_path"
319326

320327
# Commit to encrypted repo
321328
git_enc status --short
322-
git_enc commit -m "$(git_plain show --format='%B' --name-status | gzip -c9 | _encrypt "" $_armor_flags)"
329+
git_enc commit -m "$(
330+
git_plain show --format='%B' --name-status |
331+
gzip -c9 |
332+
_encrypt "" $_armor_flags)"
323333
}
324334

325335

0 commit comments

Comments
 (0)