diff --git a/clone-backup.sh b/clone-backup.sh new file mode 100755 index 00000000..598f4910 --- /dev/null +++ b/clone-backup.sh @@ -0,0 +1,27 @@ +#!/bin/bash +dir="$(dirname "$0")" + +# FTP server details +LOCAL_DIR="/backup" + +keys=$(cat $dir/$2.yml | yaml2json - | jq '.volumes' | jq -r 'keys[]') + +files=() + +for key in $keys; do + volume_name="rpc_$key" + + need_to_copy_file=$($dir/list-backups.sh $1 | grep "${volume_name}" | sort | tail -n 1) + + #echo "Download: $need_to_copy_file" + files+=("$need_to_copy_file") +done + +if [ "$3" = "--print-timestamp-only" ]; then + echo "${files[@]}" + exit 0 +fi + +base_url="https://$1.stakesquid.eu/backup/" +aria2c -d "$LOCAL_DIR" "${files[@]/#/$base_url}" + diff --git a/list-backups.sh b/list-backups.sh new file mode 100755 index 00000000..a0e1a901 --- /dev/null +++ b/list-backups.sh @@ -0,0 +1,4 @@ +#!/bin/bash + + +curl -s https://$1.stakesquid.eu/backup/ | grep -oP 'rpc_[^"]*\.tar\.zst' | sort -u