diff --git a/backups-manager.sh b/backups-manager.sh index d0e37b6..0e21f44 100644 --- a/backups-manager.sh +++ b/backups-manager.sh @@ -135,7 +135,7 @@ [ -n "$3" ] && [ "$3" != "-" ] && BACKUP_PATH_SOURCE=$3 [ -n "$4" ] && [ "$4" != "-" ] && BACKUP_PATH_TARGET=$4 [ -n "$5" ] && RESTORE_PATH_TARGET=$5 - + [ -n "$6" ] && TARGET_ITEM=$6 CMD_INIT="$CMD init" CMD_COPY="$CMD backup" @@ -144,6 +144,7 @@ CMD_MOUNT="$CMD mount" CMD_CLEAN="$CMD prune" CMD_RESTORE="$CMD restore" + CMD_FORGET="$CMD forget" CMD_ARCHIVE="$ARCHIVER -c $ROOT/.c " CMD_ARCHIVE_CREATE="$CMD_ARCHIVE mb" @@ -629,7 +630,7 @@ _do_show() { [ -z "$1" ] && echo "no user found " && return [ -z "$2" ] && echo "no source found " && return - _set_passwd_file "$1" && echo "No credentials found for $1" && return 1 + ! _set_passwd_file "$1" && echo "No credentials found for $1" && return 1 local source="" source=$(_get_target "$2") # shellcheck disable=SC2086 @@ -653,17 +654,28 @@ _do_clean() { [ -z "$1" ] && echo "no user found " && return [ -z "$2" ] && echo "no source found " && return - _set_passwd_file "$1" && echo "No credentials found for $1" && return 1 + ! _set_passwd_file "$1" && echo "No credentials found for $1" && return 1 local source="" source=$(_get_target "$2") # shellcheck disable=SC2086 $CMD_CLEAN $HOST_ARGS $CMD_OPS -r $source } + _do_forget() { + [ -z "$1" ] && echo "no user found " && return + [ -z "$2" ] && echo "no source found " && return + [ -z "$3" ] && echo "no target found target_item " && return + ! _set_passwd_file "$1" && echo "No credentials found for $1" && return 1 + local target=$3 + local source="" + source=$(_get_target "$2") + # shellcheck disable=SC2086 + $CMD_FORGET $HOST_ARGS $CMD_OPS -r $source $target + } _do_mount() { [ -z "$1" ] && echo "no user found " && return [ -z "$2" ] && echo "no source found " && return [ -z "$3" ] && echo "no target found " && return - _set_passwd_file "$1" && echo "No credentials found for $1" && return 1 + ! _set_passwd_file "$1" && echo "No credentials found for $1" && return 1 local target=$3 if [[ "$target" =~ "@" ]] ; then target=$(echo "$target" | cut -d"@" -f2 | sed 's,^/,,g') @@ -729,6 +741,12 @@ _set_cmd_ops _do_mount "$2" "$4" "$restore_path" ;; + forget) + _set_cmd_ops + local target_item="" + [ -n "$TARGET_ITEM" ] && target_item=$TARGET_ITEM + _do_forget "$2" "$4" "$target_item" + ;; clear|clean) _set_cmd_ops _do_clean "$2" "$4" "$5"