Most efficient way to backup variables

Hello, I am fairly new to the whole PLC Next platform and PLC Next engineer, currently we are using version 2020.0 LTS. For my current project I have various variables (config settings and hour counters) which are configured as retain variables, during a powercycle all variables keep their values as intended. But during downloads everything is set to the initial values (obviously), because this is rather annoying for e.g. an hour counters I want to implement an automatic backup of some of the variables. Could you point me in the right direction how this can be done with this platform? I was thinking about one of the following options, but maybe you have other (better) options:

                                             1. Install and use 'Datalogger' app from app store 
                                                * <https://www.plcnextstore.com/#/169>
                                             2. Write variables to file at certain times and create an option to read the file back to the variables.

I do not need any historical values, just a way to restore the current settings. Thank you! Kind regards, Mike

Hello Mike,

there is no such functionality in the Datalogger library to my knowledge. I suggest saving the variables to a file and restoring data from that file on demand If the PLC starts with initial values.
The format to store the data is to your choice, a byte array might work fine but if you want it human readable maybe something like json would be a nice option.

I also suggest you store the File at the /tmp directory regularily and only move that file to the SD on demand to keep the writecycles to a minimum.
(You probably want to take Shutdown/Restart ect events as an indicator when to store data…) Some hints can be found here or here.

kind regards,
Oliver Warneke

Hi Oliver, Many thanks for your answer, at the moment I’m busy with another project, but I will try to implement this in my program as soon as possible. I will come back to you when it’s done or when I have further questions. Kind regards, Mike

Hi The newest firmware 2020.6.1. uses Extented Retain handeling, and works much better than the 2020.LTS. FW.

Try that one. Now it’s keeping the retain values in case of download. - Emil