Add 24 files
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 14s

This commit is contained in:
j
2026-02-26 15:04:20 +13:00
parent 26b74f91a5
commit 1a61eec6ac
12 changed files with 423 additions and 0 deletions

26
tailscale-relay/restore.sh Executable file
View File

@@ -0,0 +1,26 @@
#!/bin/bash
# shellcheck disable=SC1091
source "${AGENT_PATH}/common.sh"
_check_required_env_vars "CONTAINER_NAME" "BACKUP_FILE" "TEMP_DIR"
if ! lxc info "${CONTAINER_NAME}" 2>/dev/null | grep -q "Status: RUNNING"; then
_die "Container ${CONTAINER_NAME} must be running for restore. Run install.sh first."
fi
mkdir -p "${TEMP_DIR}/restore"
tar -xzf "${BACKUP_FILE}" -C "${TEMP_DIR}/restore"
echo "Restoring Tailscale state..."
# Stop tailscale before restoring state
lxc exec "${CONTAINER_NAME}" -- systemctl stop tailscaled 2>/dev/null || true
# Push state archive into container and extract
lxc file push "${TEMP_DIR}/restore/tailscale-state.tgz" "${CONTAINER_NAME}/tmp/tailscale-state.tgz" || _die "Failed to push backup to container"
lxc exec "${CONTAINER_NAME}" -- bash -c "rm -rf /var/lib/tailscale/* && tar -xzf /tmp/tailscale-state.tgz -C /var/lib/tailscale" || _die "Failed to extract state"
lxc exec "${CONTAINER_NAME}" -- rm -f /tmp/tailscale-state.tgz
# Restart tailscale
lxc exec "${CONTAINER_NAME}" -- systemctl start tailscaled
echo "Restore completed successfully"