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)
- Open any tmux session:
tmux new -s work - continuum detects no saved state and restores the last backup automatically
Manual
- Open any tmux session
- Press
Ctrl+Space Ctrl+r - 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
- Install tmux and TPM
- Copy
~/.tmux.confand install plugins (Ctrl+Space I) - Copy the resurrect backup directory:
rsync -av old-server:~/.local/share/tmux/resurrect/ \~/.local/share/tmux/resurrect/
- Open tmux and press
Ctrl+Space Ctrl+r