Backup Mastodon toots/pouets to MongoDB

This flow saves your toots to a MongoDB instance. This is done by using the madonctl utility. Just configure the utility like you would do normally and put the binary in a place Node-RED can call via exec node. You also need to provide the Yaml configuration file since it's needed by the command line used in the exec node.

I chose /data/bin/ because /data is the directory the Dockerized Node-RED uses as a volume/persistent storage.

id of the toot is used as _id key

[{"id":"e9e4dafd.9d3d18","type":"inject","z":"3e11b2d0.76150e","name":"","topic":"","payload":"","payloadType":"date","repeat":"14400","crontab":"","once":true,"x":470,"y":660,"wires":[["f859909f.6517e"]]},{"id":"f859909f.6517e","type":"exec","z":"3e11b2d0.76150e","command":"/data/bin/madonctl --config /data/madonctl.yaml -o json accounts statuses --all","addpay":false,"append":"","useSpawn":"","timer":"","name":"Madonctl","x":620,"y":660,"wires":[["8877d86d.3a5fb8"],[],[]]},{"id":"8877d86d.3a5fb8","type":"json","z":"3e11b2d0.76150e","name":"","x":770,"y":660,"wires":[["aaada394.1000b"]]},{"id":"aaada394.1000b","type":"split","z":"3e11b2d0.76150e","name":"","splt":"\\n","x":910,"y":660,"wires":[["7195f97d.11a868"]]},{"id":"7195f97d.11a868","type":"change","z":"3e11b2d0.76150e","name":"","rules":[{"t":"move","p":"payload.id","pt":"msg","to":"payload._id","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1100,"y":660,"wires":[["ea8ad2df.8e2ae"]]},{"id":"ea8ad2df.8e2ae","type":"mongodb out","z":"3e11b2d0.76150e","mongodb":"1eba365a.74776a","name":"toot toot","collection":"pouets","payonly":true,"upsert":false,"multi":false,"operation":"store","x":1300,"y":680,"wires":[]},{"id":"1eba365a.74776a","type":"mongodb","z":"","hostname":"127.0.0.1","port":"27017","db":"mastodon","name":""}]
juzam

Flow Info

created 6 months ago

Node Types

Core
  • change (x1)
  • exec (x1)
  • inject (x1)
  • json (x1)
  • mongodb (x1)
  • mongodb out (x1)
Other
  • split (x1)

Tags

  • mastodon
  • mongodb
  • toots
Copy this flow JSON to your clipboard and then import into Node-RED using the Import From > Clipboard (Ctrl-I) menu option