How-tos  Scripts  Pricing  Testimonials  Support  Newsletter

This minimalist script depends only on programs from OpenBSD base. To encrypt your files use bioctl(8) with CRYPTO, openssl(1), or scrypt.

If you are looking for a deduplicating archiver, try borg(1).

Tested on OpenBSD 6.3

Archive with mtree(8) and pax(1)

arc is an archiver with compression. It creates a spec of the original file tree with mtree(8), then creates a compressed archive with pax(1) and gzip(1).


$ ftp -Vo ~/bin/arc
arc          100% |********************| 18711       00:00
$ chmod +x ~/bin/arc

Create an archive

$ arc ~/src /tmp/archive
/home/romanzolotarev/src 24080K /tmp/archive 16752K OKAY
$ ls -1 /tmp/archive*

Extract a file

Restore one file from the archive and compare its contents with the original.

$ cd /tmp
$ pax -pe -rzf /tmp/archive ./www/
$ diff ~/src/www/ ./www/

Extract all files

arc_extract restores whole archive into current directory and compares restored files with the spec created by mtree(8).

Note: time of original files in spec is in nanoseconds, while pax(1) restores time in seconds. Therefore, we use sed to cut nanoseconds.

$ mkdir -p /tmp/restored && cd /tmp/restored
$ arc_extract archive

or just do the same manually:

$ mkdir -p /tmp/restored && cd /tmp/restored
$ pax -pe -rzf /tmp/archive
$ gunzip < /tmp/archive.tree.gz > /tmp/archive.tree
$ sha256 < tree; cat /tmp/archive.tree.sha256
$ sed 's/time=\([0-9]*\)\.[0-9]*/time=\1.0/' /tmp/archive.tree|mtree

© 2008–2019 Roman Zolotarev  User Agreement  Privacy Policy