For performance reasons I would like to stack tmpfs on top of the working directory of some programs. However, the program needs to access data previously saved in the "real" working directory, sometimes lots of data. So, instead of copying the whole folder to tmpfs, I thought of using OverlayFs in a similar fashion to DeepFreeze.
However, I would like to make the data persistent when unmounting the union (for example on poweroff), overwriting previous files with the same path, and leaving the other untouched.
Is there a way to automatically do this, without the user having to remember to "sync" the folders? I cannot find a feature of OverlayFs for this, and the alternative I could think of, namely a umount hook, seems not practical to implement.