Back-up SQLite Database

Im working with Node-Red to send MQTT data to a SQLite database and Provide data in an organized manner.

My Question, Is their a way to Backup the SQLite database automatically from Node-Red or another way to do it. I'm trying to get away from manually having to do this.

I'm using a simple script, executed with cron. See Sqlite — Kanboard documentation

A SQLite db is just a file isn't it? So you can use your normal backup capabilities to do it.

For example, I have some BASH scripts that do daily, weekly, monthly backups of my whole node-red installation. Using links to keep the size to a minimum (and not backing up the node_modules folders which are easily replaced with a npm install). These run on CRON schedules so that I don't have to think about them.

Just copying the file won't work because the database index get corrupted.
I'm using an exec node with the settings as show below. with the sqlite backup command.
This will make a backup of the sqlite database. This will lock the sqlite dbase temporary to make a backup.
You can trigger the exec node (daily) with the trigger node.

As always, a simple search gives most of the answer:

How to backup sqlite database? - Stack Overflow

android - What is the best way to take backup of sqlite database? - Stack Overflow

The EXEC node is what I'm looking for. So I can back it up in the same directory fine, But can I use this to back it up using a mounted external usb drive.

I tried and the node keeps throwing an error. But backs up perfect within the same folder.

Show us how you have configured the node and what the error is. Just saying that it throws the error gives us no clues at all.

Capture

This is how I configured it, and the node gives an error when backing up to mounted drive.

It works fine when I use ".backup /tmp/sqlite.backup"

Does the command run in a terminal? If not then it won't run in node-red

If it does run in a terminal then you still haven't told us what the error is. If necessary Look on all the outputs of the exec node with debug nodes configured to show Complete Message.

Command works in terminal and creates backup, but I was hoping the exec node automatically backs it up

Here is a picture of the error on node

There is no point me making suggestions if you ignore them:

That helped, Thanks

For the benefit of anyone else finding this thread please tell us what the problem was.

It was my bad, Im still relatively new to linux. Permissions problem within the folder.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.