Files
main-desktop/scripts/restore.sh
T
ckochandClaude Opus 5 1ddc56800a Move to Ubuntu 26.04 LTS: backup, setup and restore scripts
Replaces the Bazzite/BlueBuild image with plain Ubuntu. apt covers the system
and dev tools, Flathub the desktop apps, and three scripts do the rest:
backup.sh archives this machine's home to server-marvin and reads it back to
verify it; setup.sh builds a fresh 26.04 install (NVIDIA 595-open, Docker with
GPU access, Steam/Lutris, 27 Flatpaks, VS Code, Claude desktop, the Data drive
and marvin mounts); restore.sh unpacks the backup without the Fedora/KDE parts
that would fight Ubuntu.

The app list comes from a scan of the running machine. The 15 Flatpaks left
behind sit commented at the bottom of flatpaks.txt, and their data still rides
along in the backup. No Node or .NET on the host by choice — LudosData and
landingPage build in Docker.

Drops the BlueBuild recipe, the cosign key and the old dev-setup script. The
Bazzite setup stays in this history.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-23 15:48:47 -04:00

91 lines
4.1 KiB
Bash
Executable File

#!/usr/bin/env bash
# Run on Ubuntu AFTER setup.sh and a reboot. Unpacks the Bazzite backup into your home,
# minus the Fedora/KDE-specific bits that would fight a fresh Ubuntu desktop.
#
# scripts/restore.sh # newest desktop-backup-* on server-marvin
# scripts/restore.sh /path/to/backup # a specific backup folder
# ONLY="home steam-saves" scripts/restore.sh # just some archives
#
# Everything is still in the archives, so anything skipped here can be pulled out later:
# tar -I zstd -xf home.tar.zst -C ~ ./.config/some-app
set -euo pipefail
SHARE=/mnt/server-marvin-personal
step() { printf '\n\033[1;34m== %s ==\033[0m\n' "$*"; }
die() { printf '\033[1;31merror:\033[0m %s\n' "$*" >&2; exit 1; }
[[ $EUID -ne 0 ]] || die "run as your user, not with sudo"
ls "$SHARE" >/dev/null 2>&1 || true # poke the automount
SRC="${1:-$(ls -d "$SHARE"/desktop-backup-* 2>/dev/null | sort | tail -1)}"
[[ -n $SRC && -d $SRC ]] || die "no backup found — pass the folder, or check $SHARE is mounted"
ONLY=${ONLY:-home steam-saves xlcore comfyui}
echo "Restoring from $SRC: $ONLY"
pgrep -x steam >/dev/null && die "quit Steam first"
# Flatpak apps need a GL extension matching the NVIDIA driver, and flatpak can only see the
# driver version once it's loaded — i.e. now, after the reboot. Without this they render in software.
step "Flatpak NVIDIA runtime"
sudo flatpak update -y --noninteractive
# Old configs (Heroic, Lutris, XIVLauncher, Proton prefixes, ...) hold absolute
# /var/home/ckoch/... paths. One symlink makes all of them resolve on Ubuntu.
[[ -e /var/home ]] || sudo ln -s /home /var/home
# Left out of home.tar.zst on purpose:
skip=(
--anchored
# Fedora's shell dotfiles; Ubuntu's are better and setup.sh already added what's needed
--exclude=./.bashrc --exclude=./.bash_profile --exclude=./.bash_logout --exclude=./.profile
--exclude=./.bashrc.d --exclude=./.zshrc --exclude=./.zprofile
# .NET tool shims built against Homebrew's SDK (setup.sh reinstalled dotnet-ef)
--exclude=./.dotnet
# pip --user installs for Fedora's Python, and launchers for the old distroboxes
--exclude=./.local/bin --exclude='./.local/lib/python*'
--exclude='./.local/share/applications/claude*'
--exclude='./.local/share/applications/war1gus*'
--exclude=./.local/share/applications/code.desktop
# desktop state that would clobber Ubuntu's: GNOME's settings db, keyring, default apps,
# and KDE-generated GTK themes that would recolor GNOME apps
--exclude=./.config/dconf --exclude=./.local/share/keyrings --exclude=./.config/mimeapps.list
--exclude=./.config/gtk-3.0 --exclude=./.config/gtk-4.0
--exclude=./.config/gtkrc --exclude=./.config/gtkrc-2.0 --exclude=./.gtkrc-2.0
# Bazzite leftovers
--exclude=./.config/bazzite --exclude=./.config/autostart/sb-key-notify.desktop
# old SMB password file (setup.sh stored the credentials in /etc/samba)
--exclude=./.smbcredentials
)
for name in $ONLY; do
f="$SRC/$name.tar.zst"
step "$name"
[[ -f $f ]] || { echo "not in backup, skipping"; continue; }
args=()
[[ $name == home ]] && args=("${skip[@]}")
tar --extract --file="$f" --use-compress-program=zstd --directory="$HOME" \
--checkpoint=100000 --checkpoint-action='ttyout= %{%H:%M:%S}t %T%*\r' \
"${args[@]}"
echo "ok"
done
# Claude Code keys memory/history by folder path; /var/home/ckoch is now /home/ckoch.
if [[ -d ~/.claude/projects ]]; then
for d in ~/.claude/projects/-var-home-*; do
[[ -d $d ]] || continue
new=~/.claude/projects/${d##*/-var}
[[ -e $new ]] || mv "$d" "$new"
done
[[ -f ~/.claude.json ]] && sed -i 's#"/var/home/#"/home/#g' ~/.claude.json
fi
step "Done — a few things to finish by hand"
cat <<EOF
- Steam: open it, sign in, then Settings > Storage > Add drive > /mnt/data/SteamLibrary
(games on the Data drive come back without downloading; home-drive games redownload).
- ComfyUI: rebuild its venv —
cd ~/ComfyUI && python3 -m venv venv && venv/bin/pip install -r requirements.txt
- Old pip --user tools (rembg etc.) weren't restored: pipx install "rembg[cli]" if you want it.
- Log out and back in so every app picks up the restored settings.
EOF