Skip to main content

Session Persistence & Recovery

On this server, tmux sessions are automatically saved and can be restored after a reboot or crash.

How It Works

Two plugins work together to provide session persistence:

  • tmux-resurrect — Manual save (Ctrl+Space Ctrl+s) and restore (Ctrl+Space Ctrl+r)
  • tmux-continuum — Auto-save every 15 minutes and restore on startup

See the tmux-resurrect and tmux-continuum pages for plugin details.

Backup Location

All backups are stored in ~/.local/share/tmux/resurrect/:

~/.local/share/tmux/resurrect/
├── tmux_resurrect_<timestamp>.txt ← individual backups
├── last ← symlink to most recent backup
└── pane_contents.tar.gz ← pane text snapshots

Multiple backups are kept — you can browse the directory to find a specific point in time.

The Backup Hook

Every save (manual or automatic) triggers a post-save hook that copies the backup to a git-tracked directory:

~/github/common-config/tmux/gc-sg-m16/continuum/<date>/
└── tmux-resurrect-<hostname>-<filename>

The hook also cleans up backups older than 60 days:

find ~/github/common-config/tmux/gc-sg-m16/continuum/ \
-mindepth 2 -type f -mtime +60 -delete

This ensures the archive stays manageable while preserving recent history.

Recovery After Reboot

Automatic (if @continuum-restore is on)

  1. Open any tmux session: tmux new -s work
  2. continuum detects no saved state and restores the last backup automatically

Manual

  1. Open any tmux session
  2. Press Ctrl+Space Ctrl+r
  3. All sessions, windows, panes, and configured programs are restored

Before a Planned Reboot

Run a manual save to ensure the latest state is captured:

# Inside tmux: Ctrl+Space Ctrl+s
# Or from command line:
tmux run-shell '~/.tmux/plugins/tmux-resurrect/scripts/save.sh'

Migrating to a New Machine

  1. Install tmux and TPM
  2. Copy ~/.tmux.conf and install plugins (Ctrl+Space I)
  3. Copy the resurrect backup directory:
    rsync -av old-server:~/.local/share/tmux/resurrect/ \
    ~/.local/share/tmux/resurrect/
  4. Open tmux and press Ctrl+Space Ctrl+r