2
2
=====
3
3
4
4
[ ![ 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 )
7
7
[ ![ Script size] ( https://img.shields.io/github/size/kernc/myba/myba.sh?style=for-the-badge&color=skyblue )] ( https://github.com/kernc/myba )
8
8
[ ![ Issues] ( https://img.shields.io/github/issues/kernc/myba?style=for-the-badge )] ( https://github.com/kernc/myba/issues )
9
9
[ ![ Sponsors] ( https://img.shields.io/github/sponsors/kernc?color=pink&style=for-the-badge )] ( https://github.com/sponsors/kernc )
@@ -112,7 +112,8 @@ Installation
112
112
To install everything on a Debian/Ubuntu-based system, run:
113
113
``` sh
114
114
# 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
116
117
117
118
# Download and put somewhere on PATH
118
119
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!
126
127
It should be similar, if not nearly equivalent, to install on other platforms.
127
128
Hopefully you will find most dependencies already satisfied.
128
129
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!
130
132
131
133
132
134
Usage
@@ -141,20 +143,27 @@ Subcommands:
141
143
add [OPTS] PATH... Stage files for backup/version tracking
142
144
rm PATH... Stage-remove files from future backups/version control
143
145
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)
145
147
pull [REMOTE] Pull encrypted commits from a promisor remote
146
148
clone REPO_URL Clone an encrypted repo and init from it
147
149
remote CMD [OPTS] Manage remotes of the encrypted repo
148
150
decrypt [--squash] Reconstruct plain repo commits from encrypted commits
151
+ reencrypt Reencrypt plain repo commits with a new password
149
152
diff [OPTS] Compare changes between plain repo revisions
150
153
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
151
157
checkout PATH... Sparse-checkout and decrypt files into $WORK_TREE
152
158
checkout COMMIT Switch files to a commit of plain or encrypted repo
153
159
gc Garbage collect, remove synced encrypted packs
154
160
git CMD [OPTS] Inspect/execute raw git commands inside plain repo
155
161
git_enc CMD [OPTS] Inspect/execute raw git commands inside encrypted repo
156
162
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)
158
167
```
159
168
160
169
@@ -190,15 +199,19 @@ export WORK_TREE="$HOME"
190
199
myba init
191
200
myba add Documents Photos Etc .dotfile
192
201
PASSWORD=' secret' myba commit -m " my precious"
193
- myba remote add origin " /media/usb/backup"
202
+ myba remote add origin " /media/usb/backup/path "
194
203
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
196
205
197
206
# Somewhere else, much, much later, avoiding catastrophe ...
198
207
199
208
export WORK_TREE=" $HOME "
200
209
PASSWORD=' secret' myba clone " ..." # Clone one of the known remotes
201
210
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)
202
215
```
203
216
See [ _ smoke-test.sh_ ] ( https://github.com/kernc/myba/blob/master/smoke-test.sh ) file for a more full example & test case!
204
217
@@ -211,24 +224,25 @@ The script is considered _mostly_ feature-complete, but there remain
211
224
bugs and design flaws to be discovered and ironed out, as well as any
212
225
[ TODOs and FIXMEs] ( https://github.com/search?q=repo%3Akernc%2Fmyba+%28todo+OR+fixme+OR+xxx%29&type=code )
213
226
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 .
217
230
218
231
219
232
FAQ
220
233
---
221
234
<div markdown =" 1 " property =" about " typeof =" FAQPage " >
222
235
223
236
<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 >
225
238
<div markdown =" 1 " property =" acceptedAnswer " typeof =" Answer " ><div markdown =" 1 " property =" text " >
226
239
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:
228
242
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,
232
246
* efficiently compress non-binary files,
233
247
* [ apply custom script filters] ( https://git-scm.com/book/ms/v2/Customizing-Git-Git-Attributes ) to files
234
248
based on file extension / glob string match,
@@ -242,7 +256,23 @@ with long and rigorous release / support cycles.
242
256
243
257
</div ></div ></details >
244
258
<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 >
246
276
<div markdown =" 1 " property =" acceptedAnswer " typeof =" Answer " ><div markdown =" 1 " property =" text " >
247
277
248
278
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.
263
293
264
294
</div ></div ></details >
265
295
<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 >
267
297
<div markdown =" 1 " property =" acceptedAnswer " typeof =" Answer " ><div markdown =" 1 " property =" text " >
268
298
269
299
Git saves whole file snapshots and doesn't do any in-file or within-file
270
300
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.
272
303
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,
274
305
** _ myba_ only ever uses sparse-checkout** , keeping overhead disk space use to a minimum.
275
306
276
307
</div ></div ></details >
277
308
<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 >
279
310
<div markdown =" 1 " property =" acceptedAnswer " typeof =" Answer " ><div markdown =" 1 " property =" text " >
280
311
281
312
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
292
323
293
324
</div ></div ></details >
294
325
<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 >
296
361
<div markdown =" 1 " property =" acceptedAnswer " typeof =" Answer " ><div markdown =" 1 " property =" text " >
297
362
298
363
Myba constructs encrypted repo commits _ after_ successful plain repo commits.
299
364
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.
302
370
303
371
** 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.
305
373
306
374
Myba only ** deletes redundant encrypted blobs after successfully pushing to _ all_ configured remotes** ,
307
375
and ** never deletes or overwrites existing files in work tree** unless forced!
308
376
309
377
</div ></div ></details >
310
378
<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 >
312
380
<div markdown =" 1 " property =" acceptedAnswer " typeof =" Answer " ><div markdown =" 1 " property =" text " >
313
381
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).
315
386
316
387
</div ></div ></details >
317
388
</div >
0 commit comments