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