Linux OSBN/Ubuntuusers Planet XING / LinkedIn

Node-RED Flow backups using Git

Node-RED is particularly popular in home automation. For example, the free framework can be used to playfully create processes (“turn on light”) that react dynamically to events (“if it’s evening”) – and that with low-code. The logic clicked together via drag & drop can then be exported via JSON, for example, and saved as a backup – if you think of it.

Newer Node-RED versions include projects functionality which already serves Git integration – so the following steps aren’t needed, anymore!

Backing up the logic is done with a few mouse clicks – so individual or all flows can be exported and also imported again. However, it is a manual process that tends to be forgotten. Once an export is done, the files still need to be stored and versioned in a meaningful way afterwards.

Whenever possible, I always use Git to version files and document changes. Unfortunately, there doesn’t seem to be much usable Git extensions for Node-RED – a semi-useful one is node-red-contrib-git-ui. This is installed as follows:

$ npm i -S node-red-contrib-git-ui

After restarting the application/container, the extension is active.

An SSH key should now be generated for the container/application user so that content can be maintained without entering a password:

$ ssh-keygen

A Git repository is now created in the application folder (/data when using the Docker container) and a staging branch is created. This is necessary because the extension unfortunately only updates flow changes in this branch.

$ cd /data
$ git init .
$ git checkout -b staging

Then the URL of an empty remote repository is configured:

$ git remote add ssh://...

Since the extension unfortunately automatically deposits all changed files in Git, the overview suffers. The remedy is to create a .gitignore allowlist that only allows flow-relevant files:


Afterwards, a git-ui entry can be found in the dropdown menu on the right – a commit can simply be triggered here. In the log submenu, past commits can also be viewed, compared and restored:

If you are looking for an easy way to backup flows regularly with Git, you should take a look at the extension. However, it would be nice if the documentation was better and there were more settings options.

Sharing is caring

2 Comments Add New Comment

    1. Christian says:

      no there are no real benefits – after I published the blog post I discovered the projects functionality.

      I’ll add an hint to the post, that this isn’t required anymore – thanks for pointing out!

      Best wishes,

Leave a Reply

Your email address will not be published.