To enable persistent variables in nodered you need to change:

/usr/lib/node_modules/node-red

uncomment this lines:

    /** Context Storage
     * The following property can be used to enable context storage. The configuration
     * provided here will enable file-based context that flushes to disk every 30 seconds.
     * Refer to the documentation for further options: https://nodered.org/docs/api/context/
     */
    contextStorage: {
        default: {
            module:"localfilesystem"
        },
    },

after an update you need to do it again!. Global variables are now persistent.

Update: After update 3.50 this don't work anymore at all!!