From 48681cfd4d08cfa14b3ebf52fbac9807d204ecce Mon Sep 17 00:00:00 2001 From: Hektor Misplon Date: Sat, 21 Oct 2023 17:11:53 +0200 Subject: [PATCH] Add basic ssh host backup script --- .bin/save-ssh-host | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100755 .bin/save-ssh-host diff --git a/.bin/save-ssh-host b/.bin/save-ssh-host new file mode 100755 index 0000000..a994e2c --- /dev/null +++ b/.bin/save-ssh-host @@ -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