Easily archive entire directories in whichever manner you wish.
1# Archiver
2Archiver is a bash script that helps you backup whatever you want, however you
3want.
4
5## Usage
6
7For example:
8`archive.json`
9```json
10[
11 {
12 "name": "Wallpapers",
13 "target": "~/Media/Pictures/Wallpapers",
14 "archive": {
15 "name": "walls",
16 "destination": "~/OneDrive/Wallpapers"
17 },
18 "timestamps": {
19 "last_archive": 1712438594,
20 "last_upload": 1712438693
21 },
22 "sync_command": "onedrive --synchronize --single-directory 'Wallpapers'",
23 "md5sum": "6de26f11ad638fd145f3d1412e0bf1c6"
24 },
25 {
26 "name": "Books",
27 "target": "~/Documents/Books",
28 "archive": {
29 "name": "books",
30 "destination": "~/OneDrive/Books"
31 },
32 "timestamps": {
33 "last_archive": 1712439022,
34 "last_upload": 1712439638
35 },
36 "sync_command": "onedrive --synchronize --single-directory 'Books'",
37 "md5sum": "b4ae6185bb5a20d19c0b30f9778a10cb"
38 }
39]
40```
41
42You specify list of attribute sets with three key parts:
43- `target`: the target directory you wish to backup
44- `archive`: the name of the archive and where you want to store the archive
45- `sync_command`: the command you wish to use to back up this specific directory
46
47Other details like `timestamps` and `name` are useful for other purposes if you
48wish to climb under the hood to use them.
49
50The MD5-Sum is also useful if you wish to verify the legitimacy of your files
51after retrieving them.
52
53*PS:* an example `archives.json` is provided.
54
55## Methodology
561. Your `target` gets converted into a tarball.
572. That tarball is compressed into an `xz` archive.
58 - This format was chosen because of its excellent compression ratio.
59 - Though in the future I would like to implement multiple formats for this.
603. A parity archive is created from that compressed tarball.
61 - Uses the `par2cmdline` utilities.
62 - A single block file with 30% redundancy is created.
63 - Additionally, you can use the index file that's created but `par2` doesn't really need it.
644. A unix timestamp and MD5-Sum is taken from the archived tarball.
655. Your `sync_command` hook is run at the end and a secondary timestamp is taken
66 at the end of this.
676. Your `archives.json` file is updated with all of the fresh timestamps and
68 MD5-Sum.
69
70## dependencies
71- `tar`
72- `xz`
73- `stat`
74- `par2create` (from `par2cmdline` package)
75- `md5sum`
76- `du`
77- `awk`
78- `jq`
79
80## TODO
81- [ ] Multiple archiving formats.
82- [ ] Store `archives.json` in a user-specified directory.
83- [ ] Multiple block file parity archive.
84- [ ] Multi-threaded archiving.