Automate Flow Backup


Is there a way to automate the flow backup? I see we can export all flows but it would be good to have a nightly process to back this up.

Something we can schedule in a cron using CLI or even better, create a backup flow that will backup all of the tabs?



Node-RED logs the name of the flow file when it starts up. You can setup whatever process you want to copy that and the accompanying credentials file (same as your flow file, but with _creds added) to wherever you want.

There is also the Projects feature that allows you to have version control integrated with the editor.



To answer your question:
You might take a look at
both by the same author. They seem similar, the second having more features and requirements. I used the first for while but stopped because I was getting lots of time-stamped backups with no easy way to tell what was in them.

To answer your problem:
I agree with @knolleary that the NR Projects feature might be the best answer to, for example, recovering from your mistakes. If you want protection from SD card corruption or other hardware failures, that's a different problem.

1 Like


I also use NR Projects, but as I quite often forget to commit and push changes :tired_face: so I also use a NR flow which I wrote to automatically backup NR (as well as emoncms data files) to a .tar.gz archive file, and then upload it to Dropbox -

Once set up, it keeps up to 30 days worth of backups, and the older ones are automatically weeded off, so it's 'fit & forget'.

If you only want to backup node-red, just delete out the lines relating to emoncms, from within the 'Generate Commands' function node & renumber the execution order, as per the example below;

var path = '/home/pi/.temp_nodered/';
// Don't change this
var tmp_path = '/tmp/NR_backup/';

//Generate days to add to archive title
var d = new Date();
var day = new Array(7);
day[0]=  "Sun";
day[1] = "Mon";
day[2] = "Tue";
day[3] = "Wed";
day[4] = "Thu";
day[5] = "Fri";
day[6] = "Sat";

//Create directory structure
var m1={payload: "rm -rf "+[path]};
var m2={payload: "mkdir "+[path]};
var m3={payload: "mkdir "+[tmp_path]};

// ************************************************************************* //
// *** The below commands will archive the entire node-red user directory,
// *** To add further commands, use the same format, and add the
// ***  corresponding msg id to the 'return' statement.
// ************************************************************************* //
  //Create ~/.node-red archive
  var m4={payload: "tar -czvf "+[path]+(day[d.getDay()])+"_nodered"+".tar.gz /home/pi/.node-red"};
  var m10={payload: "rm -rf "+[tmp_path]}; //delete old tmp directory from RAM
// ****************************************************** //
// Output the commands for execution
return [ [ m1, m2, m3, m4, m10 ] ];