From acb462d15e020d3a465b500659ed36a2e4c466ee Mon Sep 17 00:00:00 2001 From: John Date: Sun, 27 Apr 2025 20:26:39 +1200 Subject: [PATCH] Fix logic --- src/main_commands.cpp | 8 ++------ templates/example-nginx/restore.sh | 3 --- templates/example-nginx/uninstall.sh | 4 ++-- 3 files changed, 4 insertions(+), 11 deletions(-) diff --git a/src/main_commands.cpp b/src/main_commands.cpp index 70533cf..10c77b4 100644 --- a/src/main_commands.cpp +++ b/src/main_commands.cpp @@ -132,18 +132,14 @@ int restore(const std::vector &args) } std::cout << "Backup complete." << std::endl; } - { // silently uninstalling the current service - std::cout << "2) Uninstalling current service..." << std::endl; - env.run_remote_template_command(service_name, "uninstall", {}, false); - } { // restore service from backup - std::cout << "3) Restoring service from backup..." << std::endl; + std::cout << "2) Restoring service from backup..." << std::endl; env.run_remote_template_command(service_name, "restore", {local_backup_file_path}, false); } // healthcheck the service - std::cout << "4) Healthchecking service..." << std::endl; + std::cout << "3) Healthchecking service..." << std::endl; std::string green_tick = "\033[32m✓\033[0m"; std::string red_cross = "\033[31m✗\033[0m"; if (env.run_remote_template_command(service_name, "status", {}, false)) diff --git a/templates/example-nginx/restore.sh b/templates/example-nginx/restore.sh index d816bd4..3377119 100644 --- a/templates/example-nginx/restore.sh +++ b/templates/example-nginx/restore.sh @@ -22,9 +22,6 @@ fi # # Stop container before backup bash ./uninstall.sh || die "Failed to uninstall service before restore" -_is_container_running && die "Container still running after uninstall" -_is_container_exists && die "Container still exists after uninstall" - # Remove existing data folder echo "Deleting ALL data in $LOCAL_DATA_FOLDER." rm -rf "$LOCAL_DATA_FOLDER" diff --git a/templates/example-nginx/uninstall.sh b/templates/example-nginx/uninstall.sh index b469139..58afb63 100644 --- a/templates/example-nginx/uninstall.sh +++ b/templates/example-nginx/uninstall.sh @@ -9,8 +9,8 @@ source "$(dirname "$0")/_common.sh" check_required_env_vars "CONTAINER_NAME" "IMAGE_REGISTRY" "IMAGE_REPO" "IMAGE_TAG" _remove_container $CONTAINER_NAME || die "Failed to remove container ${CONTAINER_NAME}" -_is_container_running || die "Couldn't stop existing container" -_is_container_exists || die "Couldn't remove existing container" +_is_container_running && die "Couldn't stop existing container" +_is_container_exists && die "Couldn't remove existing container" # remove the image docker rmi "$IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG" || echo "Failed to remove image $IMAGE_REGISTRY/$IMAGE_REPO:$IMAGE_TAG"