Skip to content

Instantly share code, notes, and snippets.

@jkeam
Created July 16, 2026 16:02
Show Gist options
  • Select an option

  • Save jkeam/427974ada770120ae5b4c1dcd8a8ad57 to your computer and use it in GitHub Desktop.

Select an option

Save jkeam/427974ada770120ae5b4c1dcd8a8ad57 to your computer and use it in GitHub Desktop.
OpenClaw Restore Script
#!/bin/bash
# Bender's Certified Ultimate OS & Agent Restore System
# Usage: ./restore_system.sh <path_to_backup_directory>
set -e
BACKUP_DIR="$1"
if [ -z "$BACKUP_DIR" ]; then
echo "❌ Error: Please specify the path to the backup directory."
echo "Usage: $0 /path/to/backup/2026-07-16_hours-11"
exit 1
fi
# Convert to absolute path
BACKUP_DIR=$(realpath "$BACKUP_DIR")
if [ ! -d "$BACKUP_DIR" ]; then
echo "❌ Error: Backup directory not found at $BACKUP_DIR"
exit 1
fi
echo "πŸš€ Initiating system restoration sequence from: $BACKUP_DIR"
echo "=========================================================="
# 1. Restore Fedora DNF Packages
if [ -f "$BACKUP_DIR/fedora-packages.txt" ]; then
echo "πŸ“¦ Re-installing Fedora DNF packages..."
sudo dnf install -y $(cat "$BACKUP_DIR/fedora-packages.txt")
else
echo "⚠️ fedora-packages.txt not found, skipping package re-installation."
fi
# 2. Restore local custom binaries to /usr/local/bin
if [ -f "$BACKUP_DIR/local-binaries.tar.gz" ]; then
echo "πŸ› οΈ Restoring custom binaries to /usr/local/bin..."
sudo tar -xzf "$BACKUP_DIR/local-binaries.tar.gz" -C /
else
echo "⚠️ local-binaries.tar.gz not found, skipping."
fi
# 3. Restore shell profiles
echo "🐚 Restoring shell profile configs..."
cp "$BACKUP_DIR/.bashrc" "$BACKUP_DIR/.bash_profile" ~/ 2>/dev/null || echo "⚠️ Shell profiles not found in backup."
# 4. Restore SSH config
if [ -d "$BACKUP_DIR/ssh-config" ]; then
echo "πŸ”‘ Restoring SSH keys and configurations..."
mkdir -p ~/.ssh
cp -r "$BACKUP_DIR/ssh-config/"* ~/.ssh/
chmod 700 ~/.ssh
chmod 600 ~/.ssh/* 2>/dev/null || true
else
echo "⚠️ ssh-config folder not found, skipping."
fi
# 5. Restore Systemd User Services
if [ -d "$BACKUP_DIR/systemd-user-services" ]; then
echo "βš™οΈ Restoring Systemd User Services..."
mkdir -p ~/.config/systemd/user
cp -r "$BACKUP_DIR/systemd-user-services/"* ~/.config/systemd/user/
systemctl --user daemon-reload
else
echo "⚠️ systemd-user-services folder not found, skipping."
fi
# 6. Restore OpenClaw state & workspace
OPENCLAW_TAR=$(find "$BACKUP_DIR" -name "*-openclaw-backup.tar.gz" | head -n 1)
if [ -n "$OPENCLAW_TAR" ] && [ -f "$OPENCLAW_TAR" ]; then
echo "πŸ€– Restoring OpenClaw State and Workspace..."
if [ -d ~/.openclaw ]; then
echo " -> Backing up existing ~/.openclaw to ~/.openclaw.old..."
rm -rf ~/.openclaw.old
mv ~/.openclaw ~/.openclaw.old
fi
mkdir -p ~/.openclaw
tar -xzf "$OPENCLAW_TAR" --strip-components=3 -C /
echo "βœ… OpenClaw state and workspace extracted successfully."
else
echo "❌ Error: OpenClaw backup tarball not found in $BACKUP_DIR!"
exit 1
fi
echo "=========================================================="
echo "πŸŽ‰ RESTORATION COMPLETE!"
echo "To restart Bender, run:"
echo " systemctl --user restart openclaw-gateway"
echo "=========================================================="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment