From a81c05cd5d866d2266c763bb3808ac811f03b312 Mon Sep 17 00:00:00 2001 From: Sebastian <379651+czarly@users.noreply.github.com> Date: Sat, 21 Dec 2024 07:05:07 +0100 Subject: [PATCH] update to extract without storing the archive when /backup doesn't exist --- clone-backup.sh | 20 +++++++++++++++++++- restore-volumes.sh | 11 ++++++----- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/clone-backup.sh b/clone-backup.sh index 50d6fecd..78f9963f 100755 --- a/clone-backup.sh +++ b/clone-backup.sh @@ -25,5 +25,23 @@ if [ "$3" = "--print-timestamp-only" ]; then fi base_url="$1" -aria2c -c -Z -x8 -j8 -s8 -d "$LOCAL_DIR" "${files[@]/#/$base_url}" + +if [ ! -d "$backup_dir" ]; then + echo "WARN: /backup directory does not exist - extracting directly" + + for file in "${files[@]}"; do + echo "Processing: $file" + curl -# "${base_url}${file}" | zstd -d | tar -xvf - -C / + + if [ $? -ne 0 ]; then + echo "Error processing $file" + exit 1 + else + echo "$file successfully processed." + fi + done +else + aria2c -c -Z -x8 -j8 -s8 -d "$LOCAL_DIR" "${files[@]/#/$base_url}" +fi + diff --git a/restore-volumes.sh b/restore-volumes.sh index df67754f..fd71c3f4 100755 --- a/restore-volumes.sh +++ b/restore-volumes.sh @@ -7,11 +7,6 @@ backup_dir="/backup" # Path to the volume directory volume_dir="/var/lib/docker/volumes" -if [ ! -d "$backup_dir" ]; then - echo "Error: /backup directory does not exist" - exit 1 -fi - if [ ! -d "$volume_dir" ]; then echo "Error: /var/lib/docker/volumes directory does not exist" exit 1 @@ -20,6 +15,12 @@ fi if [[ -n $2 ]]; then echo "download backup from http" $dir/clone-backup.sh $2 $1 + +else + if [ ! -d "$backup_dir" ]; then + echo "Error: /backup directory does not exist" + exit 1 + fi fi calculate_required_space() {