# Node-red flow for archiving to dropbox

**URL:** <https://community.openenergymonitor.org/t/node-red-flow-for-archiving-to-dropbox/5293>\
**Category:** Integrations\
**Created:** [7 October 2017 20:48 UTC](https://community.openenergymonitor.org/t/node-red-flow-for-archiving-to-dropbox/5293 "2017-10-07T20:48:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Paul](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/paul/32/28_2.png) [@Paul](https://community.openenergymonitor.org/u/Paul)\
**Post date:** [7 October 2017 20:48 UTC](https://community.openenergymonitor.org/t/node-red-flow-for-archiving-to-dropbox/5293/1 "2017-10-07T20:48:29Z")

</div>

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](https://gist.github.com/Paul-Reed/c29cfa755fed666805956eb6da42a0d0)

**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](https://github.com/jprichardson/node-fs-extra).

TO INSTALL FS-EXTRA

```auto
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

---

<div class="post-metadata">

**Author:** ![Pukka](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/p/d07c76/32.png) [@Pukka](https://community.openenergymonitor.org/u/Pukka)\
**Post date:** [19 May 2018 16:38 UTC](https://community.openenergymonitor.org/t/node-red-flow-for-archiving-to-dropbox/5293/2 "2018-05-19T16:38:57Z")

</div>

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

 ![image](https://community.openenergymonitor.org/uploads/default/original/2X/1/15ecd9cb88063ad4c85c679c0d7f3cb011c40071.png)

Any ideas?

---

<div class="post-metadata">

**Author:** ![Paul](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/paul/32/28_2.png) [@Paul](https://community.openenergymonitor.org/u/Paul)\
**Post date:** [19 May 2018 17:34 UTC](https://community.openenergymonitor.org/t/node-red-flow-for-archiving-to-dropbox/5293/3 "2018-05-19T17:34:22Z")

</div>

Have you added the Dropbox node to your node-red palette?  
[node-red-node-dropbox](https://flows.nodered.org/node/node-red-node-dropbox)

Paul

---

<div class="post-metadata">

**Author:** ![Pukka](https://community.openenergymonitor.org/letter_avatar_proxy/v4/letter/p/d07c76/32.png) [@Pukka](https://community.openenergymonitor.org/u/Pukka)\
**Post date:** [19 May 2018 19:37 UTC](https://community.openenergymonitor.org/t/node-red-flow-for-archiving-to-dropbox/5293/4 "2018-05-19T19:37:22Z")

</div>

That solved the problem. 🙂

---

<div class="post-metadata">

**Author:** ![borpin](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/borpin/32/193_2.png) [@borpin](https://community.openenergymonitor.org/u/borpin)\
**Post date:** [20 May 2018 11:12 UTC](https://community.openenergymonitor.org/t/node-red-flow-for-archiving-to-dropbox/5293/5 "2018-05-20T11:12:53Z")

</div>

> [@Paul](#):
>
> Just been working on a new node-red flow, to perform backups to dropbox if anyone is interested.

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

---

<div class="post-metadata">

**Author:** ![Paul](https://community.openenergymonitor.org/user_avatar/community.openenergymonitor.org/paul/32/28_2.png) [@Paul](https://community.openenergymonitor.org/u/Paul)\
**Post date:** [20 May 2018 11:48 UTC](https://community.openenergymonitor.org/t/node-red-flow-for-archiving-to-dropbox/5293/6 "2018-05-20T11:48:33Z")

</div>

Yes, correct.
