From a32c5f9a43067ed8de577f5fd6813552c191a5a8 Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Sat, 8 May 2021 12:20:00 +0200 Subject: [PATCH] chg: [0km] use new ``ssh-key`` api ``get-type`` to discover type of backup Signed-off-by: Valentin Lab --- bin/0km | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/bin/0km b/bin/0km index 83388ef..be24c6e 100755 --- a/bin/0km +++ b/bin/0km @@ -842,25 +842,18 @@ cmdline.spec:vps-backup:cmd:recover:run() { admin=${BACKUP_TARGET%%@*} server=${BACKUP_TARGET#*@} - ## XXXvlab: in this first implementation we expect to have access - ## to the server main ssh port 22, so we won't use the provided port. - # ssh_options=() + ssh_options=() if [[ "$server" == *":"* ]]; then - # ssh_options+=(-p "${server#*:}") + ssh_options+=(-p "${server#*:}") ssh_server=${server%%:*} fi BACKUP_PATH="/srv/datastore/data/rsync-backup-target/var/mirror" - if ! rtype=$(echo " - if [ -d '$BACKUP_PATH/$id/var/lib/docker/volumes/mailcowdockerized_crypt-vol-1' ]; then - echo mailcow - elif [ -d '$BACKUP_PATH/$id/compose.yml' ]; then - echo compose - fi - true - " | ssh:run "root@${ssh_server}" -- bash ); then + if ! rtype=$(ssh:run "$admin"@"${ssh_server}" "${ssh_options[@]}" -- ssh-key get-type "$id" ); then err "Could not get backup type." + echo " Do you have admin access to $admin@$server ?" >&2 + echo " Are you sure '$id' backup identifier belongs to '$admin' admin on '$server' ?" >&2 return 1 fi