Created
July 16, 2026 16:02
-
-
Save jkeam/427974ada770120ae5b4c1dcd8a8ad57 to your computer and use it in GitHub Desktop.
OpenClaw Restore Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/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