Using the exec node to automate database backups

hi
I'm fairly new to node-red and am trying to automate execution of a command.

A bit of background. I am setting up a number of IOT sensors to collect data for a project I have. I am using a MING (Mosquitto, InfluxDB, Node-red, and Grafana) stack to collect the data points from the sensors, store them (influxdb) and display them. For now the server is running on a raspberry pi. I've used docker to set up the MING stack and it is running well.

I now would like to set up a backup for the InfluxDB database. I have mounted a shared folder back to my NAS at /home/dr/lab_data to hold it. Docker provides a command to export containers (eg Influxdb) into a .tar file.

sudo docker export -o /home/dr/lab_data/ influxdb

I can execute the command manually and it creates a .tar file in the location and now would like to automate this in code red.

I haven't been able to get the exec node to work.

simply inserting the above command returns error 127 with ...
Command failed: sudo docker export -o /home/dr/lab_data/test influxdb
/bin/bash: line 1: sudo: command not found

I have tried including the command in the injected message payload but this doesn't work.

any constructive suggestions would be welcome

You will not be able to execute sudo commands from node-red. You will need to add the user to the sudo group, or do it a 'more' node-red-way, use a node like dockerode to execute docker commands

This is how I backup the influx database from an Exec node.
Tar file is generate in the /home/nodered/dbs/backup_ex directory.

Don't know if it will work in Docker.

This is not strictly true. You could edit sudoers to turn off the need for a password prompt for that command. Of course, this may be something of a security issue so should only be done after careful thought about possible consequences.

Is node red also running in Docker? If so, does that command run if you execute it from inside the node red docker container?