Add 24 files
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 14s
All checks were successful
Test and Publish Templates / test-and-publish (push) Successful in 14s
This commit is contained in:
20
tailscale-relay/backup.sh
Executable file
20
tailscale-relay/backup.sh
Executable file
@@ -0,0 +1,20 @@
|
||||
#!/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}" &>/dev/null; then
|
||||
_die "Container ${CONTAINER_NAME} does not exist."
|
||||
fi
|
||||
|
||||
mkdir -p "${TEMP_DIR}/backup"
|
||||
|
||||
# Export tailscale state from the container
|
||||
echo "Backing up Tailscale state..."
|
||||
lxc exec "${CONTAINER_NAME}" -- tar -czf /tmp/tailscale-state.tgz -C /var/lib/tailscale . 2>/dev/null || _die "Failed to archive tailscale state"
|
||||
lxc file pull "${CONTAINER_NAME}/tmp/tailscale-state.tgz" "${TEMP_DIR}/backup/tailscale-state.tgz" || _die "Failed to pull backup from container"
|
||||
lxc exec "${CONTAINER_NAME}" -- rm -f /tmp/tailscale-state.tgz
|
||||
|
||||
tar -czf "${BACKUP_FILE}" -C "${TEMP_DIR}/backup" .
|
||||
|
||||
echo "Backup completed successfully"
|
||||
Reference in New Issue
Block a user