Skip to content

Commit bdaf675

Browse files
committed
DOC: Update README.full
1 parent f632123 commit bdaf675

File tree

3 files changed

+100
-29
lines changed

3 files changed

+100
-29
lines changed

.github/scripts/build-website.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ h1 {line-height: 1.3em;}
3232
a:link {color:navy}
3333
a:hover {color:blue !important}
3434
a:visited {color:#230}
35-
summary {width:fit-content; border:2px solid silver; cursor:pointer; padding:.2em .6em; margin:.3em 0; font-weight:bold}
35+
summary {width:fit-content; border:2px solid silver; cursor:pointer; padding:.2em .6em; margin:.3em 0}
3636
details[open] summary {border:2px solid black;}
3737
</style>
3838
<meta property="og:title" content="Myba - git-based file backup with encryption">

README.full.md

Lines changed: 98 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
=====
33

44
[![Build status](https://img.shields.io/github/actions/workflow/status/kernc/myba/ci.yml?branch=master&style=for-the-badge)](https://github.com/kernc/myba/actions)
5-
[![Language: shell / Bash](https://img.shields.io/badge/lang-Shell-skyblue?style=for-the-badge)](https://github.com/kernc/myba)
6-
[![Source lines of code](https://img.shields.io/endpoint?url=https://ghloc.vercel.app/api/kernc/myba/badge?filter=myba.sh$&style=for-the-badge&color=skyblue&label=SLOC)](https://github.com/kernc/myba)
5+
[![Language: shell / Bash](https://img.shields.io/badge/lang-Shell-peachpuff?style=for-the-badge)](https://github.com/kernc/myba)
6+
[![Source lines of code](https://img.shields.io/endpoint?url=https%3A%2F%2Fghloc.vercel.app%2Fapi%2Fkernc%2Fmyba%2Fbadge?filter=myba.sh%26format=human&style=for-the-badge&label=SLOC&color=skyblue)](https://ghloc.vercel.app/kernc/myba)
77
[![Script size](https://img.shields.io/github/size/kernc/myba/myba.sh?style=for-the-badge&color=skyblue)](https://github.com/kernc/myba)
88
[![Issues](https://img.shields.io/github/issues/kernc/myba?style=for-the-badge)](https://github.com/kernc/myba/issues)
99
[![Sponsors](https://img.shields.io/github/sponsors/kernc?color=pink&style=for-the-badge)](https://github.com/sponsors/kernc)
@@ -112,7 +112,8 @@ Installation
112112
To install everything on a Debian/Ubuntu-based system, run:
113113
```sh
114114
# Install dependencies
115-
sudo apt install gzip git git-lfs openssl gpg
115+
# These should be preinstalled or available on most including cloud distros
116+
sudo apt install coreutils gzip git git-lfs openssl gpg
116117

117118
# Download and put somewhere on PATH
118119
curl -vL 'https://bit.ly/myba-backup' > ~/.local/bin/myba
@@ -126,7 +127,8 @@ Note, only one of `openssl` _or_ `gpg` is needed, not both!
126127
It should be similar, if not nearly equivalent, to install on other platforms.
127128
Hopefully you will find most dependencies already satisfied.
128129

129-
Please report back if you find / manage to get this working under everything but the above configuration and especially Windows/WSL!
130+
Please report back if you find or manage to get this working under everything but the above configuration,
131+
especially Windows/WSL!
130132

131133

132134
Usage
@@ -141,20 +143,27 @@ Subcommands:
141143
add [OPTS] PATH... Stage files for backup/version tracking
142144
rm PATH... Stage-remove files from future backups/version control
143145
commit [OPTS] Commit staged changes of tracked files as a snapshot
144-
push [REMOTE] Encrypt and push files to remote repo(s) (default: all)
146+
push [REMOTE] Push encrypted repo to remote repo(s) (default: all)
145147
pull [REMOTE] Pull encrypted commits from a promisor remote
146148
clone REPO_URL Clone an encrypted repo and init from it
147149
remote CMD [OPTS] Manage remotes of the encrypted repo
148150
decrypt [--squash] Reconstruct plain repo commits from encrypted commits
151+
reencrypt Reencrypt plain repo commits with a new password
149152
diff [OPTS] Compare changes between plain repo revisions
150153
log [OPTS] Show commit log of the plain repo
154+
status [OPTS] Show git status of the plain repo
155+
ls-files [OPTS] Show current backup files (OPTS go via git ls-tree)
156+
largest List current backup files by file size, descending
151157
checkout PATH... Sparse-checkout and decrypt files into $WORK_TREE
152158
checkout COMMIT Switch files to a commit of plain or encrypted repo
153159
gc Garbage collect, remove synced encrypted packs
154160
git CMD [OPTS] Inspect/execute raw git commands inside plain repo
155161
git_enc CMD [OPTS] Inspect/execute raw git commands inside encrypted repo
156162
157-
Env vars: WORK_TREE, PLAIN_REPO, PASSWORD, USE_GPG, VERBOSE, YES_OVERWRITE, ...
163+
PLAIN repo <--encryption--> ENCRYPTED repo <--synced with--> git REMOTE
164+
165+
Env vars: WORK_TREE, PLAIN_REPO, PASSWORD, USE_GPG, VERBOSE, YES_OVERWRITE,
166+
GIT_LFS_THRESH (in bytes)
158167
```
159168

160169

@@ -190,15 +199,19 @@ export WORK_TREE="$HOME"
190199
myba init
191200
myba add Documents Photos Etc .dotfile
192201
PASSWORD='secret' myba commit -m "my precious"
193-
myba remote add origin "/media/usb/backup"
202+
myba remote add origin "/media/usb/backup/path"
194203
myba remote add github "git@github.com:user/my-backup.git"
195-
VERBOSE=1 myba push # Push to all configured remotes & free up disk space
204+
VERBOSE=1 myba push # Push to ALL configured remotes & free up disk space
196205

197206
# Somewhere else, much, much later, avoiding catastrophe ...
198207

199208
export WORK_TREE="$HOME"
200209
PASSWORD='secret' myba clone "..." # Clone one of the known remotes
201210
myba checkout ".dotfile" # Restore backed up files in a space-efficient manner
211+
212+
# When already cloned ...
213+
myba pull # Sync encrypted remote
214+
myba decrypt # Restore plain commits (original files)
202215
```
203216
See [_smoke-test.sh_](https://github.com/kernc/myba/blob/master/smoke-test.sh) file for a more full example & test case!
204217

@@ -211,24 +224,25 @@ The script is considered _mostly_ feature-complete, but there remain
211224
bugs and design flaws to be discovered and ironed out, as well as any
212225
[TODOs and FIXMEs](https://github.com/search?q=repo%3Akernc%2Fmyba+%28todo+OR+fixme+OR+xxx%29&type=code)
213226
marked in the source.
214-
**All source code lines are open to discussion.**
215-
Especially appreciated are targets for simplification
216-
and value-added testing.
227+
All source code lines are **open to discussion.
228+
Always appreciate a healthy refactoring**, simplification,
229+
and value-added tests.
217230

218231

219232
FAQ
220233
---
221234
<div markdown="1" property="about" typeof="FAQPage">
222235

223236
<details markdown="1" property="mainEntity" typeof="Question">
224-
<summary property="name">Is git a good tool for backups?</summary>
237+
<summary property="name">Is <b>git a suitable tool</b> for maintaining backups?</summary>
225238
<div markdown="1" property="acceptedAnswer" typeof="Answer"><div markdown="1" property="text">
226239

227-
The inherently core features of git/myba allow you to:
240+
While most sources will advise using (their) standalone solution,
241+
the inherently core features of git and thus myba allow you to:
228242

229-
* track a list of important files,
230-
* track all changes made, with authorship info and datums, to any of the tracked files,
231-
* securely store copies of files at each commited snapshot,
243+
* track lists of important files,
244+
* track file modification info and changes made,
245+
* securely store copies of files of each commited snapshot,
232246
* efficiently compress non-binary files,
233247
* [apply custom script filters](https://git-scm.com/book/ms/v2/Customizing-Git-Git-Attributes) to files
234248
based on file extension / glob string match,
@@ -242,7 +256,23 @@ with long and rigorous release / support cycles.
242256

243257
</div></div></details>
244258
<details markdown="1" property="mainEntity" typeof="Question">
245-
<summary property="name">Can git track file owner and permissions etc.?</summary>
259+
<summary property="name"><b>How does myba differ</b> from other backup tools like Bacula, Borg, Duplicity, restic, luckyBackup and git-crypt?</summary>
260+
<div markdown="1" property="acceptedAnswer" typeof="Answer"><div markdown="1" property="text">
261+
262+
myba simply wraps raw git and is written in pure, standard **POSIX shell for maximum portability**
263+
and ease of use. It's got the exactly familiar git CLI API.
264+
265+
myba does file-based (as opposed to block-based) differencing and encryption.
266+
267+
Compared to git-crypt, <b>myba also encrypts the committed path/filenames</b> for maximum privacy.
268+
269+
*[POSIX]: Portable Operating System Interface
270+
*[CLI]: Command Line Interface
271+
*[API]: Application Programming Interface
272+
273+
</div></div></details>
274+
<details markdown="1" property="mainEntity" typeof="Question">
275+
<summary property="name">Can git track <b>file owner and permissions etc.</b>?</summary>
246276
<div markdown="1" property="acceptedAnswer" typeof="Answer"><div markdown="1" property="text">
247277

248278
Git doesn't on its own track file owner and permission changes (other than the executable bit).
@@ -263,19 +293,20 @@ you find widely-applicable and useful.
263293

264294
</div></div></details>
265295
<details markdown="1" property="mainEntity" typeof="Question">
266-
<summary property="name">Can we use git for continually changed databases and binary files?</summary>
296+
<summary property="name">Can we use git for <b>often-changing binaries</b> like databases?</summary>
267297
<div markdown="1" property="acceptedAnswer" typeof="Answer"><div markdown="1" property="text">
268298

269299
Git saves whole file snapshots and doesn't do any in-file or within-file
270300
or across-file deduplication, so it's not well-suited to automatic continual backing up
271-
of databases (i.e. large binaries) that change often.
301+
of databases (i.e. large binaries) that change often,
302+
unless both repos are also regularly squashed, pruned and gc'd.
272303

273-
However, while git repositories bloat when commiting such **large binary and media files**,
304+
However, while git repositories bloat when commiting such large binary and media files,
274305
**_myba_ only ever uses sparse-checkout**, keeping overhead disk space use to a minimum.
275306

276307
</div></div></details>
277308
<details markdown="1" property="mainEntity" typeof="Question">
278-
<summary property="name">How to influence what files / filetypes to (ignore from) backup?</summary>
309+
<summary property="name">How to influence <b>what files / filetypes to (ignore from) backup</b>?</summary>
279310
<div markdown="1" property="acceptedAnswer" typeof="Answer"><div markdown="1" property="text">
280311

281312
You stage files and directories for backup with version control as normally, with `myba add`.
@@ -292,26 +323,66 @@ by modifying respective files in `$PLAIN_REPO` and (encrypted repo) `$PLAIN_REPO
292323

293324
</div></div></details>
294325
<details markdown="1" property="mainEntity" typeof="Question">
295-
<summary property="name">Encryption failed. How do I investigate / recover?</summary>
326+
<summary property="name">Use custom <b>pre-commit hook scripts</b> to conditionally backup some "data" at commit time ...</summary>
327+
<div markdown="1" property="acceptedAnswer" typeof="Answer"><div markdown="1" property="text">
328+
329+
You can use [git hooks] to "attach" own scripts to the backup process,
330+
namely the [`pre-commit`][git hooks] hook.
331+
332+
[git hooks]: https://git-scm.com/docs/githooks#_pre_commit
333+
334+
For example, to save own music library or some such only in list form,
335+
one could e.g. do:
336+
337+
```shell
338+
# ${WORK_TREE:-$HOME}/.myba/hooks/pre-commit:
339+
#!/bin/sh
340+
wt="$GIT_WORK_TREE"
341+
if git diff --cached --name-only | grep -q '^Music/'; then
342+
ls -lR "$wt/path_of_interest" > "$wt/mylist.txt"
343+
git add "$wt/mylist.txt" # Will be committed
344+
fi
345+
```
346+
347+
</div></div></details>
348+
<details markdown="1" property="mainEntity" typeof="Question">
349+
<summary property="name">How to do <b>incremental directory backups?</b></summary>
350+
<div markdown="1" property="acceptedAnswer" typeof="Answer"><div markdown="1" property="text">
351+
352+
When you `myba add` a file directory, an identifying hidden file
353+
called `.mybabackup` gets created in it.
354+
Afterwards, whenever you invoke `myba commit`, any newly added or changed files
355+
in that directory are staged for that snapshot / commit.
356+
357+
</div></div></details>
358+
359+
<details markdown="1" property="mainEntity" typeof="Question">
360+
<summary property="name"><b>Something failed</b>. How do I <b>debug, investigate, and recover</b>?</summary>
296361
<div markdown="1" property="acceptedAnswer" typeof="Answer"><div markdown="1" property="text">
297362

298363
Myba constructs encrypted repo commits _after_ successful plain repo commits.
299364

300-
Use `myba git` and `myba git_enc` subcommands to discover what state you're in (e.g. `myba git status`).
301-
Then use something like `myba git reset HEAD^ ; myba git_enc reset HEAD` to reach an acceptable state.
365+
Use `myba git` (run with git files in `PLAIN_REPO=`, mirroring contents of `WORK_TREE=`)
366+
and `myba git_enc` (run in `$PLAIN_REPO/_encrypted`) subcommands to
367+
discover what state you're in (e.g. `myba git status`).
368+
Then use something like `myba git reset HEAD^ ; myba git_enc reset HEAD`
369+
(or similar, as appropriate) to reach an acceptable state.
302370

303371
**If it looks like a bug, please report it.**
304-
Otherwise git will let you know what the problem is.
372+
Otherwise git should let you know what the problem is.
305373

306374
Myba only **deletes redundant encrypted blobs after successfully pushing to _all_ configured remotes**,
307375
and **never deletes or overwrites existing files in work tree** unless forced!
308376

309377
</div></div></details>
310378
<details markdown="1" property="mainEntity" typeof="Question">
311-
<summary property="name">Can I get a simple backup contents archive?</summary>
379+
<summary property="name">Can I get a <b>compressed archive</b> of backup contents?</summary>
312380
<div markdown="1" property="acceptedAnswer" typeof="Answer"><div markdown="1" property="text">
313381

314-
Easily. You can run e.g.: [`myba git archive --output backup.zip HEAD`](https://git-scm.com/docs/git-archive).
382+
For backing up files externally, see `remote add origin "/media/usb/backup/path"` example above.
383+
384+
If you want a compressed archive, you can run e.g.: [`myba git archive --output backup.zip HEAD`](https://git-scm.com/docs/git-archive)
385+
(or `myba git_enc archive --output state.zip HEAD`, as found appropriate).
315386

316387
</div></div></details>
317388
</div>

myba.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ cmd_reencrypt() {
333333

334334
WORK_TREE="$temp_dir" # Don't switcheroo "live" config files!
335335

336-
# Loop through plain commit hashes, checkout into temp location, and redo a cmd_commit
336+
# Loop through plain commit hashes and checkout & cmd_commit
337337
git_plain log --reverse --pretty=format:'%H' |
338338
while _read_vars commit_hash; do
339339
# shellcheck disable=SC2154

0 commit comments

Comments
 (0)