From 1df451aeb644413b45bf75ccd3c3f596f8252439 Mon Sep 17 00:00:00 2001 From: 57_Wolve <57_wolve@private.email> Date: Mon, 19 Jan 2026 21:45:46 +0000 Subject: [PATCH] Update multiplane.sh --- multiplane.sh | 62 +++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 60 insertions(+), 2 deletions(-) diff --git a/multiplane.sh b/multiplane.sh index d0fb26d..e28e816 100644 --- a/multiplane.sh +++ b/multiplane.sh @@ -193,12 +193,70 @@ upgrades_everyone_upgrades() { exit 0 } +backup_k0s() { + + if ! mkdir -p /opt/k0s/backups 2>/dev/null; then + fatal "Error: Failed to create directory /opt/k0s/backups" + exit 1 + fi + + gum spin --spinner dot --spinner.foreground 220 --title "Waiting..." -- k0sctl backup --save-path=/opt/k0s/backups && info "Backup success!" || fatal "Backup of k0s failed!" + +} + +restore_k0s() { + + gum spin --spinner dot --spinner.foreground 220 --title "Waiting..." -- k0sctl apply --restore-from $1 && info "Restore success!" || fatal "Restore of k0s failed!" + +} + your_good_your_good_your_good_and_stop() { - exit 0 + + gum pager </manifests) + +The backups created by k0s backup command have following pieces of your cluster: + +- certificates (the content of the /pki directory) +- etcd snapshot, if the etcd data store is used +- Kine/SQLite snapshot, if the Kine/SQLite data store is used +- k0s.yaml +- any custom defined manifests under the /manifests +- any image bundles located under the /images +- any helm configuration +EOF + + gum confirm "Start Backup Task?" && backup_k0s || clear; echo "Exiting..."; exit 0 + } thatll_buff_right_out_captin() { - exit 0 + + if [ ! -d "/opt/k0s/backups" ]; then + fatal "Error: directory /opt/k0s/backups does exist" + exit 1 + fi + + # Check if directory is empty + if [ -z "$(ls -A "/opt/k0s/backups" 2>/dev/null)" ]; then + fatal "Directory /opt/k0s/backups is empty. Exiting..." + exit 1 + fi + + clear; + + file=$(find /opt/k0s/backups -maxdepth 1 -type f -printf "%f\n" | gum filter --limit 1 --placeholder "Select a backup file...") + + if [ -n "$file" ]; then + full_path="/opt/k0s/backups/$file" + fi + + clear; gum confirm "Start Backup Task?" && restore_k0s $full_path || clear; echo "Exiting..."; exit 0 + } main() {