From ad80bc06ddceeabeeed41690f047015a8e7f6f2c Mon Sep 17 00:00:00 2001 From: goldsquid Date: Wed, 1 Oct 2025 14:09:12 +0700 Subject: [PATCH] new tool --- clone-node.sh | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 clone-node.sh diff --git a/clone-node.sh b/clone-node.sh new file mode 100644 index 00000000..e1cc42c7 --- /dev/null +++ b/clone-node.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +if [[ -n $2 ]]; then + echo "clone volumes via ssh to $2" +else + echo "Error: No destination provided" + exit 1 +fi + +# Read the JSON input and extract the list of keys +keys=$(cat /root/rpc/$1.yml | yaml2json - | jq '.volumes' | jq -r 'keys[]') + +# Iterate over the list of keys +for key in $keys; do + echo "Executing command with key: /var/lib/docker/volumes/rpc_$key/_data" + + source_folder="/var/lib/docker/volumes/rpc_$key/_data" + if [[ -n $2 ]]; then + tar -cf - --dereference "$source_folder" | pv -pterb -s $(du -sb "$source_folder" | awk '{print $1}') | zstd | ssh root@"$2.stakesquid.eu" "zstd -d | tar -xf - -C /" + fi +done