home · contact · privacy
Extend.
authorChristian Heller <c.heller@plomlompom.de>
Fri, 4 Apr 2025 20:48:16 +0000 (22:48 +0200)
committerChristian Heller <c.heller@plomlompom.de>
Fri, 4 Apr 2025 20:48:16 +0000 (22:48 +0200)
testing/home/desktop/.local/bin/borgplom

index adfc29e041b90d57e4d9c4525ceccbc82c637629..b48605f5752fdb60f7087cef8355d0ad89deb46a 100755 (executable)
@@ -19,12 +19,13 @@ servername_from_location() { echo "$1" | cut -d'/' -f3 | cut -d'@' -f2; }
 path_repo_location() { printf '%s' "${PATH_BORG_CONF_SECURITY}/${1}/location"; }
 
 # exits
+export BORG_EXIT_CODES=modern
 error_exit() { abort "Aborting due to $1"; }
 error_exit_with_usage() { error_exit "${1}\n\n$(print_usage)"; }
 exit_ok() { echo "$@"; exit 0; }
 
 # commands
-USAGE_INDICES='backup_keys claim help info keys orgpull'
+USAGE_INDICES='backup_keys claim help info init keys orgpull'
 
 _run_borg_with_passphrase() {
     while true; do
@@ -39,8 +40,8 @@ _run_borg_with_passphrase() {
         set -e
         if [ "${_RESULT}" = "0" ]; then
             break
-        elif [ "${_RESULT}" != "2" ]; then
-            error_exit "unexpected ${NAME_BORGAPP} error."
+        elif [ "${_RESULT}" != "52" ]; then
+            error_exit "unexpected borg error, code ${_RESULT}."
         fi
         export BORG_PASSPHRASE=
     done
@@ -123,6 +124,13 @@ CMDFNC_info() {
     borg list "${_TARGET_REPO}" | tail -5
 }
 
+USAGE_ARGS_init='SERVER_NAME'
+USAGE_DESC_init="create repo at \"$(location from servername SERVER_NAME)\""
+CMDFNC_init() {
+    expect_n_args 1 1 "${USAGE_ARGS_init}" $@
+    borg init --encryption=keyfile "$1"
+}
+
 USAGE_DESC_keys='list known repos in ID, key filename, and alleged location'
 CMDFNC_keys() {
     expect_n_args 0 0 '' $@