As @jbudd says it is very simple. I used an inject node to test it. As he also says, the only issue is that an existing file has to be deleted first, so a write file
node will also be required set to delete
.
I am sure there is probably an easy way to check if the file exists (the write file
fails with an error if the file does NOT exist) but the flow below is a quick & easy way to make this work.
[{"id":"f2497bf2a28ff845","type":"inject","z":"aa9a87195d3159a2","name":"Backup \\n HomeAutomation","props":[{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"VACUUM INTO \"/media/usbDrive/HomeAutomation.backup.db\"","x":960,"y":780,"wires":[["97392e943bb49f55","5950684d89bb9964"]]},{"id":"2ada57f15ddab389","type":"sqlite","z":"aa9a87195d3159a2","mydb":"f42c7c9d3f6857fb","sqlquery":"msg.topic","sql":"","name":"Home Automation SQL","x":1440,"y":780,"wires":[["cd25bbb477691c8c"]]},{"id":"cd25bbb477691c8c","type":"debug","z":"aa9a87195d3159a2","name":"SQlite Out","active":true,"tosidebar":true,"console":false,"tostatus":true,"complete":"true","targetType":"full","statusVal":"payload","statusType":"auto","x":1670,"y":780,"wires":[]},{"id":"5950684d89bb9964","type":"file","z":"aa9a87195d3159a2","name":"Delete SQLite \\n Backup","filename":"/media/usbDrive/HomeAutomation.backup.db","filenameType":"str","appendNewline":true,"createDir":false,"overwriteFile":"delete","encoding":"none","x":1220,"y":860,"wires":[[]]},{"id":"b8368113e717f06a","type":"catch","z":"aa9a87195d3159a2","name":"Catch File Error","scope":["5950684d89bb9964"],"uncaught":false,"x":1220,"y":940,"wires":[["b40e4ff7cafd4abc"]]},{"id":"b40e4ff7cafd4abc","type":"debug","z":"aa9a87195d3159a2","name":"No File","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":1420,"y":940,"wires":[]},{"id":"97392e943bb49f55","type":"delay","z":"aa9a87195d3159a2","name":"","pauseType":"delay","timeout":"10","timeoutUnits":"milliseconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":1210,"y":780,"wires":[["2ada57f15ddab389"]]},{"id":"f42c7c9d3f6857fb","type":"sqlitedb","db":"/media/usbDrive/HomeAutomation.db","mode":"RWC"}]