backup/borg/entrypoint.sh

29 lines
515 B
Bash
Executable File

#! /bin/bash
function main() {
set -e
set -u
Borgmatic --init --encryption repokey --verbosity 1 >&2 || true
if [ "$#" -gt 0 ]; then
Borgmatic "$@"
else
Borgmatic --prune --verbosity 1
Borgmatic --create --progress --verbosity 1
Borgmatic --check --verbosity 1 # expensive
fi
}
function Borgmatic() {
log borgmatic "$@"
borgmatic "$@"
}
function log() {
echo "[$(date +%Y-%m-%d-%H:%M:%S)] $@" >&2
}
if [ "$0" == "${BASH_SOURCE[0]}" ]; then
main "$@"
fi