config: Update 7 files
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 22s
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 22s
This commit is contained in:
@@ -1,55 +1,22 @@
|
||||
#!/bin/bash
|
||||
# shellcheck disable=SC1091
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
_check_required_env_vars "PROJECT_NAME" "LOCAL_DATA_FOLDER"
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
source "${SCRIPT_DIR}/_paths.sh"
|
||||
_check_required_env_vars "CONTAINER_NAME" "LOCAL_DATA_FOLDER" "BACKUP_FILE" "TEMP_DIR"
|
||||
|
||||
BACKUP_DIR="${HOME}/backups/${PROJECT_NAME}"
|
||||
# RESTORE SCRIPT
|
||||
# The restore script is OPTIONAL.
|
||||
# It is used to restore the service on the server from a backup file.
|
||||
# It is called with one argument: the path to the backup file.
|
||||
|
||||
# List available backups
|
||||
echo "Available backups:"
|
||||
ls -1t "${BACKUP_DIR}"/*.tar.gz 2>/dev/null | head -10 | nl
|
||||
# # Stop container before backup
|
||||
"${SCRIPT_DIR}/uninstall.sh" || _die "Failed to uninstall service before restore"
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "No backups found in ${BACKUP_DIR}"
|
||||
exit 1
|
||||
fi
|
||||
# shellcheck disable=SC2046
|
||||
restore_items $(get_squashkiwi_streaming_paths) || _die "Failed to restore data folder from backup"
|
||||
|
||||
# Select backup
|
||||
read -p "Enter backup number to restore (or path to backup file): " selection
|
||||
# reinstall service
|
||||
"${SCRIPT_DIR}/install.sh" || _die "Failed to reinstall service after restore"
|
||||
|
||||
if [[ -f "$selection" ]]; then
|
||||
BACKUP_FILE="$selection"
|
||||
else
|
||||
BACKUP_FILE=$(ls -1t "${BACKUP_DIR}"/*.tar.gz 2>/dev/null | sed -n "${selection}p")
|
||||
fi
|
||||
|
||||
if [[ ! -f "$BACKUP_FILE" ]]; then
|
||||
echo "Backup file not found: ${BACKUP_FILE}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Restoring from: ${BACKUP_FILE}"
|
||||
read -p "This will overwrite current configuration. Continue? (yes/no): " confirmation
|
||||
|
||||
if [[ "$confirmation" != "yes" ]]; then
|
||||
echo "Restore cancelled"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Stop services
|
||||
bash "${SCRIPT_DIR}/stop.sh" || true
|
||||
|
||||
# Backup current config
|
||||
if [[ -d "${LOCAL_DATA_FOLDER}/config" ]]; then
|
||||
mv "${LOCAL_DATA_FOLDER}/config" "${LOCAL_DATA_FOLDER}/config.bak.$(date +%Y%m%d_%H%M%S)"
|
||||
fi
|
||||
|
||||
# Extract backup
|
||||
tar -xzf "${BACKUP_FILE}" -C "${LOCAL_DATA_FOLDER}" || _die "Failed to extract backup"
|
||||
|
||||
echo "✓ Backup restored"
|
||||
|
||||
# Restart services
|
||||
bash "${SCRIPT_DIR}/start.sh"
|
||||
|
||||
echo "Restore complete!"
|
||||
echo "Restore complete! Service is running again on port $HOST_PORT with restored website."
|
||||
|
Reference in New Issue
Block a user