Restore openhab on startup

I am trying to restore previous state of items when openhab starts. As when there are power cuts my raspberry reboots and everything is turned on. so i tried using persistence with this code:
Strategies {
default = everyChange
}
Items {

  • : strategy = everyChange, restoreOnStartup
    }
    but nothing is hapening. i have no rule setup. so i need to setup any rule

Check this [Post] (Items, Sitemap saves change switch states)it sorted the problem for me

Hello,

the strategy looks fine, however you need a persistence service it is applied to.
You might want to read this: https://github.com/openhab/openhab/wiki/Persistence
I’m using MySQL and it is working exactly like you want.
Regards,
-OLI

so i did it. used mapdp. but now openhab shows error " Failed to restore item states as persistence serv ice ‘myopenhab’ can not be queried"

Looks like you have the wrong persistence service in your openhab.cfg.
For mapdb config, refer to: https://github.com/openhab/openhab/wiki/mapdb-Persistence

i have set persistence:default=mapdb

i think its problem with timing of the exucution of the script as i am using gpio outputs. whisch are initialised after persistence