diff --git a/usr/local/bin/sh.zio.backup b/usr/local/bin/sh.zio.backup index c16edab..e73c408 100755 --- a/usr/local/bin/sh.zio.backup +++ b/usr/local/bin/sh.zio.backup @@ -6,6 +6,7 @@ else . "$(dirname "$(realpath -s "$0")")/../libexec/zio/helpers/bash.sh" fi +me_filename="$(basename "$(realpath -s "$0")")" backup_scripts_dir="$(get_config_dir "sh.zio.backup")/scripts" cache_dir="/var/cache/sh.zio.backup/restic" secrets_dir="$(get_config_dir "sh.zio.backup")/secrets" @@ -71,6 +72,39 @@ function invoke_restic() { fi } +function invoke_script() { + backup_script="$1" + + backup_script_filename="$(basename "$backup_script")" + backup_script_name="${backup_script_filename%.*}" + backup_script_name_length="${#backup_script_name}" + + say primary "-[$backup_script_name]$(repeat "-" $((80-3-$backup_script_name_length)))" + chmod +x "$backup_script" + + export -f backup_dir + export -f die + export -f forget_backup + export -f get_config_dir + export -f get_real_path + export -f invoke_restic + export -f prune_backup + export -f say + export -f start_service + export -f stop_service + export -f test_file + export backup_scripts_dir + export cache_dir + export host + export me_filename + export restic_repo_file + export restic_repo_passwd_file + export restic_path + export secrets_dir + + "$backup_scripts_dir/$backup_script_filename" +} + function backup_dir() { path="$1" args="${@:2}" @@ -101,6 +135,8 @@ function backup_dir() { --exclude "containers/storage/overlay-layers" \ --exclude-if-present ".nobackup" \ --host "$host" \ + --tag "$me_filename" \ + --tag "$(basename "$0")" \ $args "$path" fi } @@ -142,6 +178,32 @@ function stop_service() { systemctl stop $service } +if [[ "$@" == "help" ]]; then + echo "$me_filename + +Usage: + $me_filename + Run all backup scripts available in $backup_scripts_dir + + $me_filename