How to restore manually Saved State files of Terminal? My MBR crashes quite often. Normally I've multiple terminal windows and usually they're restored after crash.

However from some to time they're not restored, so for that reason I was doing the backup every hour (in cron, not Time Machine) to backup the whole ~/Library/Saved Application State including com.apple.Terminal.savedState.

However when I've replaced back my savedState folder (1. removing the old one, 2. using different type of terminal) and run Terminal - it simply doesn't work as expected (as it seems it doesn't load the state files).

Is there anything that I'm missing? Do I need to do anything extra so Terminal can recognise its state files or simply backing up more folders to keep my window states safe?

The backup folder consist data.data (48M), windows.plist (empty) and window_1.data - window_56.data files (total 55M).
It seems that the windows.plist has been corrupted during the backup, as it's empty.

The Terminal restores correctly when doing the following test:


Run Terminal.
Type anything like: echo test 1.
Kill the terminal explicitly, e.g.: killall Terminal.
Run again, it should have the previous message/state.
Removing files and restoring from it, it'll have the same state.


The corrupted .plist file can be manually rewritten by the following hacky steps:


Convert plist into its XML representation (Terminal will still recognise it):

plutil  -convert xml1 -o windows.plist windows.plist

Edit the file to match its windows id (NSWindowID) to the appropriate files. Or create as many new windows manually to have the same files, kill the terminal, replace only the window .data files and re-run again.

However if the data files are not inconsistent with plist file, the Terminal will restore the default session overriding your files.