cd - > /dev/null
USAGE_DESCRIPTION='Wrapper around certain borgbackup usages.'
-USAGE_LINES='COMMAND\nCOMMAND PATH'
+USAGE_LINES='COMMAND [ARGUMENT]...'
PATH_BORG_CONF_SECURITY="${PATH_BORG_CONF}/security"
PATH_BORG_CONF_KEYS="${PATH_BORG_CONF}/keys"
USAGE_INDICES='backup_keys claim help keys orgpull info'
_check_args_n() {
- _N_MAX_ARGS="$1"
- shift 1
- if [ "$#" -lt "${_N_MAX_ARGS}" ]; then
+ _N_MIN_ARGS="$1"
+ _N_MAX_ARGS="$2"
+ shift 2
+ if [ "$#" -lt "${_N_MIN_ARGS}" ]; then
error_exit_with_usage "missing arguments ($# instead of ${_N_MAX_ARGS})."
fi
shift "${_N_MAX_ARGS}"
USAGE_ARGS_backup_keys='PATH'
USAGE_DESC_backup_keys="copy known keys to PATH/, with their repos' server names as filenames"
CMDFNC_backup_keys() {
- _check_args_n 1 "$@"
+ _check_args_n 1 1 "$@"
_PATH_TARGET_DIR=$(realpath "$1")
if [ -e "${_PATH_TARGET_DIR}" ] && [ ! -d "${_PATH_TARGET_DIR}" ]; then
error_exit "non-directory at ${_PATH_TARGET_DIR}"
USAGE_ARGS_claim='PATH'
USAGE_DESC_claim="register file of PATH as key to repo at \"$(location_from_servername SERVERNAME)\", with SERVERNAME the filename portion of PATH"
CMDFNC_claim() {
- _check_args_n 1 "$@"
+ _check_args_n 1 1 "$@"
_PATH_SOURCE="$1"
_ensure_no_overwrite_at() {
if [ -f "$1" ]; then
USAGE_DESC_help='print this help and exit'
CMDFNC_help() {
- _check_args_n 0 "$@"
+ _check_args_n 0 0 "$@"
print_usage
}
USAGE_ARGS_info='SERVER_NAME [ARCHIVE]'
-USAGE_DESC_info='run "borg info" against repo in server of SERVER_NAME, optionally only against ARCHIVE; if latter not provided, instead list archives of repo'
+USAGE_DESC_info='run "borg info" against repo in server of SERVER_NAME, optionally only against ARCHIVE; if latter not provided, instead list most recent archives of repo'
CMDFNC_info() {
- _check_args_n 1 "$@"
+ _check_args_n 1 2 "$@"
_TARGET_REPO="$(location_from_servername ${1})"
if [ ! -z "$2" ]; then
borg info "${_TARGET_REPO}::$2"
export BORG_PASSPHRASE=
done
echo "${_INFO}"
- borg list "${_TARGET_REPO}"
+ echo "Most recent archives:"
+ borg list "${_TARGET_REPO}" | tail -5
}
USAGE_DESC_keys='list known repos in ID, key filename, and alleged location'
CMDFNC_keys() {
- _check_args_n 0 "$@"
+ _check_args_n 0 0 "$@"
_exit_ok() {
echo "(none, since directory ${1})"
exit 0
USAGE_DESC_orgpull='pull most recent org directory available in repos'
CMDFNC_orgpull() {
- _check_args_n 0 "$@"
+ _check_args_n 0 0 "$@"
_NAME_ARCHIVE=orgdir
# determine server and repo