Node-red flow for archiving to dropbox

Just been working on a new node-red flow, to perform backups to dropbox if anyone is interested.
I’ve added the flow as a gist - A node-red flow which runs an archive routine, uploading data to Dropbox for safe keeping! · GitHub

PURPOSE
The flow was predominantly written to run a nightly archive of emoncms data directories, emoncms MYSQL database, and the entire node-red user directory, uploading them to dropbox for safe keeping, but can be easily adapted for other data sources.

The resultant tar.gz files will include the ‘day of the week’ in their title, so you can quickly identify the relevant archive to restore, and at the end of 7 days, the file will be overwritten with the current day’s data. (However Dropbox retain 30 days worth of file versions - more on paid accounts, so it’s easy to locate and restore archives up to 30 days old).

For emoncms/emonpi users - please note that by default, this flow assumes that all of your data sub-directories are included in one directory which will be archived . Also, further commands would need to be added to change the filesystem to read-write, and back to read-only (easy to do - just see examples in the Generate commands node.

REQUIREMENTS
Requires the library fs-extra installing & enabling
globally in settngs.js (used in Read Filenames function node).
This is a really useful library to have anyway as it makes node.js much more functional in node-red, see here.

TO INSTALL FS-EXTRA

cd ./node-red  
npm install --save fs-extra

TO MAKE FS-EXTRA GLOBAL
Add fse:require('fs-extra') to the
functionGlobalContext section in NR settings.js file.

CONFIGURATION
Edit the Generate commands function node with
your own;

  • Emoncms data directory path
  • Emoncms MYSQL username (default = emoncms)
  • Emoncms MYSQL password

Setup the dropbox node, (details in the node info)
Also edit the Start backup inject node with your preferred time to run.
If you want to be alerted about archive problems or failures, you can use the Report any errors node output to dispatch the message via Pushover, email, twitter or whatever. Currently, the msg.topic is the message title, and msg.payload is the error message.

Paul

4 Likes

Hi Paul,

I have just rebuilt my emonpi and i am trying to setup the dropbox backup, I used an old script but i am looking at your node red version, I have added the fs-extra. when i import the flow i am see an error

Any ideas?

Have you added the Dropbox node to your node-red palette?
node-red-node-dropbox

Paul

That solved the problem. :slight_smile:

Great idea. However, I assume that the NR instance must be running on the same machine?

Yes, correct.