From ff6f4c1e874c1cfc61b57d14667ea0e76e00bb1d Mon Sep 17 00:00:00 2001 From: Sebastian <379651+czarly@users.noreply.github.com> Date: Sun, 24 Mar 2024 07:09:20 +0100 Subject: [PATCH] look at local volumes too --- restore-volumes.sh | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/restore-volumes.sh b/restore-volumes.sh index a2665c1d..41949ff6 100755 --- a/restore-volumes.sh +++ b/restore-volumes.sh @@ -52,16 +52,22 @@ for key in $keys; do volume_name="rpc_$key" newest_file=$(ls -1 "$backup_dir"/"$volume_name"* | sort | tail -n 1) - + directory="$volume_dir/rpc_$key/_data/" + [ -d "$directory" ] && existing_size=$(du -sb "$directory" | awk '{ total += $1 } END { print total }') || existing_size=0 + if [ -z "$newest_file" ]; then - if [ -z "$2" ]; then + if [[ "$2" = "--print-size-only" && $existing_size -gt 0 ]]; then + # I only want to have a theoretical file size + GB=$(echo "$existing_size / 1024 / 1024 / 1024" | bc ) + echo "$GB" + exit 0 + else echo "Error: No backup found for volume '$volume_name'" exit 1 fi fi - directory="$volume_dir/rpc_$key/_data/" restore_files+=("$newest_file") cleanup_folders+=("$directory") @@ -69,7 +75,7 @@ for key in $keys; do #echo "$volume_name: $required_space" total_space=$(echo "$total_space + $required_space" | bc) - [ -d "$directory" ] && existing_size=$(du -sb "$directory" | awk '{ total += $1 } END { print total }') || existing_size=0 + cleanup_space=$(echo "$cleanup_space + existing_size" | bc) done