This script was born out of a desire to be able to persist the state of tmux sessions to disk so that they would survive a reboot
It is very much a work in progress, but already quite useful
At the top of the script there is a section of variable definitions that can be modified to suit your needs. Currently, the options are:
sessionStore
- The directory where stored sessions will be saved. The default is~./sessions
- The
sessionStore
directory will be created if it does not exist already.
- The
maxStoredSessions
- The total number of saved sessions that will be stored. The default is5
- Once
maxStoredSessions
total backups exist, thefilesToRoll
parameter comes into play
- Once
filesToRoll
- The number of files that will be rotated out oncemaxStoredSessions
has been reached. The deafult is3
- What this means is, once
maxStoredSessions
sessions are stored insessionStore
,filesToRoll
files will be deleted fromsessionStore
in order to make room for new saves
- What this means is, once
-
The simplest usage is to just call
ruby ./tmux-persist.rb
from within the directory where the script exists. This will create a restoreable session script which can be run to re-create the tmux session at the time of execution -
A more common, and slightly more useful implementation is to add a cron entry like the following:
* * * * * <username> ruby <full path to>/tmux-persist.rb
, which will run this script once per minute, creating a constant series of backups of active tmux sessions
- Back up on-demand (or regularly via cron or any scheduler) all active tmux sessions
- Backups are created as runnable shell scripts, meaning all you have to do is run the appropriate 'backup' script, and your whole tmux session will be appropriately resotred
- Have more configurable properties
- Read from a config file
- Have command line switches
- Please feel free to submit issues or better yet PRs against features you'd like to see or bugs you come across
Credit goes to @daveosborne for the original implementation of this script