#!/bin/bash

set -euo pipefail

obnam() {
	chronic cargo run --bin obnam --quiet -- --config obnam-client-config.yaml --log-level trace $*
}

vobnam() {
	cargo run --bin obnam --quiet -- --config obnam-client-config.yaml --log-level trace $*
}

qobnam() {
	cargo run --bin obnam --quiet -- --config obnam-client-config.yaml --log-level error $*
}

files() {
	echo "REPO: $*"
	find /tmp/repo -type f -ls
	echo
}

delim() {
	echo "================================================ $*"
}

rm -rf /tmp/repo ~/.local/state/obnam/files.db
mkdir /tmp/repo

delim Start
files Before backup starts

delim Init repo
obnam repo init
files After repository has been initialized

delim Init client
obnam client init --credential default
#vobnam client list
files After client has been initialized

delim Start backup
obnam backup start
files After backup start

delim Back up a file
obnam backup add --key-name default README.md

delim Finish backup
obnam backup finish --key-name default
files After backup finish.

delim List backups
qobnam backup list
