Add basic ssh host backup script

master
Hektor Misplon 2023-10-21 17:11:53 +02:00
parent 0485edf197
commit 48681cfd4d
1 changed files with 12 additions and 0 deletions

12
.bin/save-ssh-host Executable file
View File

@ -0,0 +1,12 @@
#!/usr/bin/env bash
selected_hosts="$(ssh-hosts | fzf -m)"
for host in $selected_hosts; do
echo "Saving $host"
directories="$(ssh "$host" ls | fzf -m)"
for directory in $directories; do
echo "Saving $host:$directory"
ssh "$host" "(tar cvzf - ~/$directory)" > "${host}_${directory}.tar.gz"
done
done