#!/bin/sh
. $HOME/.bin/_config

[ -d "$1" ] || ( printf "Usage: backup <target>\n" && exit 2; )

print "Tarsnap Backup:"

_target=$(readlink -f "$1")
_key=$(pwgen -n1 8)
_date=$(date "+%Y-%m-%d %H:%M")
_host=$(uname -n)

doas tarsnap --humanize-numbers  --checkpoint-bytes 52428800 --exclude "*/.git/*" -cvf "$_host: $_target $_date ($_key)" "$_target"
