docs: Add 42 files
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 59s
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 59s
This commit is contained in:
55
squashkiwi-streaming/restore.sh
Executable file
55
squashkiwi-streaming/restore.sh
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
# shellcheck disable=SC1091
|
||||
source "${AGENT_PATH}/common.sh"
|
||||
_check_required_env_vars "PROJECT_NAME" "LOCAL_DATA_FOLDER"
|
||||
|
||||
BACKUP_DIR="${HOME}/backups/${PROJECT_NAME}"
|
||||
|
||||
# List available backups
|
||||
echo "Available backups:"
|
||||
ls -1t "${BACKUP_DIR}"/*.tar.gz 2>/dev/null | head -10 | nl
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "No backups found in ${BACKUP_DIR}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Select backup
|
||||
read -p "Enter backup number to restore (or path to backup file): " selection
|
||||
|
||||
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!"
|
Reference in New Issue
Block a user