Working on restore.
This commit is contained in:
parent
59561824c7
commit
8026070994
@ -134,19 +134,19 @@ int restore(const std::vector<std::string> &args)
|
||||
}
|
||||
{ // silently uninstalling the current service
|
||||
std::cout << "2) Uninstalling current service..." << std::endl;
|
||||
env.run_remote_template_command(service_name, "uninstall", {}, true);
|
||||
env.run_remote_template_command(service_name, "uninstall", {}, false);
|
||||
}
|
||||
|
||||
{ // restore service from backup
|
||||
std::cout << "3) Restoring service from backup..." << std::endl;
|
||||
env.run_remote_template_command(service_name, "restore", {local_backup_file_path}, true);
|
||||
env.run_remote_template_command(service_name, "restore", {local_backup_file_path}, false);
|
||||
}
|
||||
|
||||
// healthcheck the service
|
||||
std::cout << "4) 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", {}, true))
|
||||
if (env.run_remote_template_command(service_name, "status", {}, false))
|
||||
std::cout << green_tick << " Service is healthy." << std::endl;
|
||||
else
|
||||
std::cout << red_cross << " Service is NOT healthy." << std::endl;
|
||||
|
@ -20,21 +20,24 @@ if [ ! -f "$BACKUP_FILE" ]; then
|
||||
fi
|
||||
|
||||
# # Stop container before backup
|
||||
_stop_container "$CONTAINER_NAME"
|
||||
_remove_container "$CONTAINER_NAME"
|
||||
_is_container_running || die "Couldn't stop existing container"
|
||||
_is_container_exists || die "Couldn't remove existing container"
|
||||
|
||||
# Remove existing data folder
|
||||
echo "Removing existing data folder $LOCAL_DATA_FOLDER..."
|
||||
rm -rf "$LOCAL_DATA_FOLDER/*"
|
||||
echo "Deleting ALL data in $LOCAL_DATA_FOLDER."
|
||||
rm -rf "$LOCAL_DATA_FOLDER"
|
||||
[ ! -d "$LOCAL_DATA_FOLDER" ] || die "Failed to delete $LOCAL_DATA_FOLDER"
|
||||
|
||||
mkdir -p "$LOCAL_DATA_FOLDER"
|
||||
[ -d "$LOCAL_DATA_FOLDER" ] || die "Failed to create $LOCAL_DATA_FOLDER"
|
||||
|
||||
# Restore data folder from backup
|
||||
echo "Restoring data folder from backup $BACKUP_FILE..."
|
||||
if ! tar xzvf "$BACKUP_FILE" -C "$LOCAL_DATA_FOLDER"; then
|
||||
die "Failed to restore data folder from backup"
|
||||
fi
|
||||
|
||||
# reinstall service
|
||||
if ! bash ./install.sh; then
|
||||
die "Failed to reinstall service"
|
||||
fi
|
||||
bash ./install.sh || die "Failed to reinstall service after restore"
|
||||
|
||||
echo "Restore complete! Service is running again on port $HOST_PORT with restored website."
|
||||
|
Loading…
x
Reference in New Issue
Block a user