# Persistent variables?

**URL:** <https://discourse.nodered.org/t/persistent-variables/40168>\
**Category:** General\
**Created:** [1 February 2021 12:35 UTC](https://discourse.nodered.org/t/persistent-variables/40168 "2021-02-01T12:35:35Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)\
**Post date:** [1 February 2021 12:35 UTC](https://discourse.nodered.org/t/persistent-variables/40168/1 "2021-02-01T12:35:35Z")

</div>

Hi,

I am using 15 global variables in my flows, to take care of several status events. If/when I restart node-red or reboot the server, I am losing those variables. Is there any way to make then persistent through restart?

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [1 February 2021 12:37 UTC](https://discourse.nodered.org/t/persistent-variables/40168/2 "2021-02-01T12:37:38Z")

</div>

maybe this will help: [A guide to understanding 'Persistent Context'](https://discourse.nodered.org/t/a-guide-to-understanding-persistent-context/4115)

---

<div class="post-metadata">

**Author:** ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)\
**Post date:** [1 February 2021 12:40 UTC](https://discourse.nodered.org/t/persistent-variables/40168/3 "2021-02-01T12:40:52Z")

</div>

> [@zenofmud](#):
>
> A guide to understanding 'Persistent Context'

Your guide is GREAT!  
Thanks a lot.

---

<div class="post-metadata">

**Author:** ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)\
**Post date:** [8 February 2021 17:10 UTC](https://discourse.nodered.org/t/persistent-variables/40168/6 "2021-02-08T17:10:01Z")

</div>

@zenofmud Paul, is it allowed to have 2 different localfilesystem modules, like this:

```auto
contextStorage: {
                myFile1: { module: "localfilesystem"},
    	        myFile2: { module: "localfilesystem" }
    },

```

and then address them this way:

```auto
global.set("foo", 123, "myFile1");  
global.set("bar", 234, "myFIle2");

```

??

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 February 2021 17:22 UTC](https://discourse.nodered.org/t/persistent-variables/40168/7 "2021-02-08T17:22:39Z")

</div>

Does it not work?

---

<div class="post-metadata">

**Author:** ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)\
**Post date:** [8 February 2021 17:59 UTC](https://discourse.nodered.org/t/persistent-variables/40168/8 "2021-02-08T17:59:52Z")

</div>

Didn’t try...

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 February 2021 18:18 UTC](https://discourse.nodered.org/t/persistent-variables/40168/9 "2021-02-08T18:18:56Z")

</div>

If you had then you would know the answer by now.

---

<div class="post-metadata">

**Author:** ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)\
**Post date:** [8 February 2021 18:59 UTC](https://discourse.nodered.org/t/persistent-variables/40168/10 "2021-02-08T18:59:37Z")

</div>

Thank you. If you answered just YES or NO, you would have saved a lot of characters.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [8 February 2021 19:11 UTC](https://discourse.nodered.org/t/persistent-variables/40168/11 "2021-02-08T19:11:05Z")

</div>

> [@fmarzocca](#):
>
> If you answered just YES or NO, you would have saved a lot of characters

Maybe Colin didn't know or didn't have time to test it for you or was perhaps encouraging you to try it out as a voyage of discovery and self learning?

The thing about this forum is - it is literally the most active and supportive forum I have ever frequented - EVER - there are soo many helpful members who go to great lengths to help out folk but when a person doesn't try anything for themselves, we feel somewhat less motivated - I am sure you can appreciate that?

For the benefit of future readers of this thread - what were your findings? is it possible to have 2 different localfilesystem modules?

---

<div class="post-metadata">

**Author:** ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)\
**Post date:** [8 February 2021 19:38 UTC](https://discourse.nodered.org/t/persistent-variables/40168/12 "2021-02-08T19:38:50Z")

</div>

I was in a train when I wrote my messages. Now I have just reached home and I will have to test, but I was trying to save some time if someone already knew the answer. Do not assume that everyone is cheating. I do appreciate this forum, indeed. But I wasn't at my desk when I have answered the question.

I will be more careful in the future.

---

<div class="post-metadata">

**Author:** ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)\
**Post date:** [8 February 2021 19:55 UTC](https://discourse.nodered.org/t/persistent-variables/40168/13 "2021-02-08T19:55:40Z")

</div>

I confirm: yes. It works.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 February 2021 20:51 UTC](https://discourse.nodered.org/t/persistent-variables/40168/14 "2021-02-08T20:51:52Z")

</div>

Excellent, thanks. I had looked at your syntax and it looked ok, but I couldn't test it at that time. Now I know the answer should I need to do this.

Out of interest what use case do you have that needs this?

---

<div class="post-metadata">

**Author:** ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)\
**Post date:** [8 February 2021 21:14 UTC](https://discourse.nodered.org/t/persistent-variables/40168/15 "2021-02-08T21:14:33Z")

</div>

Nothing special, but I have many variables to make persistent and I am dividing them into 2 groups just to make order in my mind. In addition, in this way I can recall all the variables in a group without mixing with the other.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [22 February 2021 21:14 UTC](https://discourse.nodered.org/t/persistent-variables/40168/16 "2021-02-22T21:14:57Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
