Hi Carl-Johan,
This used to be rather complicated to achieve in MATLAB R2020a and earlier, but is very straightforward in Simulink Real-Time in R2020b and later, where all data logged using the File Log block is kept on the disk of the target machine until the max. number of file log runs specified for the real-time application is reached.
Best,
Dimitri