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
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.
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
fse:require('fs-extra') to the
functionGlobalContext section in NR settings.js file.
Generate commands function node with
- Emoncms data directory path
- Emoncms MYSQL username (default = emoncms)
- Emoncms MYSQL password
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.