Help with flow. Monthly backups not woking as expected

External nodes needed:

node-red-contrib-fan

node-red-contrib-fs-ops

Test button to test.

Given all context variables are set.
global.event_paths
(not sure if there is another.)

Description:
A file is constantly written to:
{{global.event_paths}}/AC_In.db

Every month it gets a bit on the big size.

So at 23:55 of the last day of the month, a pulse is sent in. (The empty link node)
I moves the file to {{global.event_paths}}/{{year}}/{{month}}+"_"+ filename
I hope I got that right.

So basically I have this structure:
event_path
(oh, I can't do *ASCII art. Leading spaces are deleted)
It make a directory with the name of YYYY
and the file is the month name_(file name)

It works every time I press the test button.

But every 1'st of the month when I look:
I have AC_In.db and _AC_In.db in the same directory.

Yes, I know this if for AC_Out. It is a test.

If you feel bored and wouldn't mind looking I would appreciate some help.

As I said: I press the test button. It works.
Left to the inject node injecting a pulse at 23:55 of the last day.... It doesn't.

After thought:
Yes, there is probably a better/easier way. For now please help me learn from this mistake.
I may look at optimising it - or what ever you may want to call it - later. But for the sake of the exercise please look at this and where it is failing rather than re-writing the whole thing.

Oh, the code for the inject node:

[{"id":"62315ad4.03cf1c","type":"cronplus","z":"1c428643.6f708a","name":"Monthly","outputField":"payload","timeZone":"","persistDynamic":false,"commandResponseMsgOutput":"output1","outputs":1,"options":[{"name":"Monthly","topic":"Monthly","payloadType":"str","payload":"Backup","expressionType":"cron","expression":"0 55 23 L * *","location":"","offset":"0","solarType":"all","solarEvents":"sunrise,sunset"}],"x":1770,"y":370,"wires":[["bbb7e036.106ec"]]}]

This is the flow.

[{"id":"bb227c07.e9401","type":"fs-ops-dir","z":"1c428643.6f708a","name":"","path":"SourcePath","pathType":"msg","filter":"SourceFile","filterType":"msg","dir":"payload","dirType":"msg","x":2140,"y":810,"wires":[["4af7829d.d59754","8fb3faeb.c40eb"]]},{"id":"4af7829d.d59754","type":"debug","z":"1c428643.6f708a","name":"Process","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2290,"y":730,"wires":[]},{"id":"8fb3faeb.c40eb","type":"switch","z":"1c428643.6f708a","name":"","property":"payload[0]","propertyType":"msg","rules":[{"t":"nnull"}],"checkall":"true","repair":false,"outputs":1,"x":2280,"y":810,"wires":[["5dd87aac.915abc"]]},{"id":"155a6294.866f95","type":"function","z":"1c428643.6f708a","name":"Build stuff","func":"//msg.SourcePath = msg.path + \"reboot\";\nmsg.SourcePath = msg.path;\nmsg.Destination = msg.path + msg.directory + \"/\";\nreturn msg;","outputs":1,"noerr":0,"x":1950,"y":810,"wires":[["bb227c07.e9401"]]},{"id":"5dd87aac.915abc","type":"fan","z":"1c428643.6f708a","x":2480,"y":810,"wires":[["c856459c.83654","a6d08182.d5dd68","2f7f8145.0983c6"]]},{"id":"7e18283c.c3fb2","type":"template","z":"1c428643.6f708a","name":"Fix filename","field":"Month","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{Month}}_{{SourceFile}}","output":"str","x":2500,"y":770,"wires":[["c6d29e61.3fe43","155a6294.866f95"]]},{"id":"c856459c.83654","type":"fs-ops-mkdir","z":"1c428643.6f708a","name":"","path":"SourcePath","pathType":"msg","dirname":"directory","dirnameType":"msg","mode":"777","fullpath":"directory","fullpathType":"msg","x":1970,"y":850,"wires":[["92edd23c.5ed26"]]},{"id":"a6d08182.d5dd68","type":"delay","z":"1c428643.6f708a","name":"Delay","pauseType":"delay","timeout":"2","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1940,"y":890,"wires":[["fe0401c6.579f88","4f4d6c4e.7e6c74"]]},{"id":"2f7f8145.0983c6","type":"debug","z":"1c428643.6f708a","name":"OUT","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2660,"y":810,"wires":[]},{"id":"c6d29e61.3fe43","type":"debug","z":"1c428643.6f708a","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2660,"y":770,"wires":[]},{"id":"68e9cfea.2a6958","type":"change","z":"1c428643.6f708a","name":"Set Filename here","rules":[{"t":"set","p":"SourceFile","pt":"msg","to":"AC_Out.db","tot":"str"},{"t":"move","p":"year","pt":"msg","to":"directory","tot":"msg"},{"t":"set","p":"path","pt":"msg","to":"event_paths","tot":"global"}],"action":"","property":"","from":"","to":"","reg":false,"x":2320,"y":770,"wires":[["b27baec2.f1af78","7e18283c.c3fb2"]]},{"id":"92edd23c.5ed26","type":"debug","z":"1c428643.6f708a","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2130,"y":850,"wires":[]},{"id":"fe0401c6.579f88","type":"fs-ops-move","z":"1c428643.6f708a","name":"","sourcePath":"SourcePath","sourcePathType":"msg","sourceFilename":"SourceFile","sourceFilenameType":"msg","destPath":"Destination","destPathType":"msg","destFilename":"Month","destFilenameType":"msg","link":false,"x":2140,"y":890,"wires":[["4a7752ae.68805c"]]},{"id":"4f4d6c4e.7e6c74","type":"debug","z":"1c428643.6f708a","name":"1d","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2130,"y":930,"wires":[]},{"id":"b27baec2.f1af78","type":"debug","z":"1c428643.6f708a","name":"RAW","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2480,"y":730,"wires":[]},{"id":"9e059740.fd1fa","type":"moment","z":"1c428643.6f708a","name":"Month","topic":"","input":"payload","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"MMM","locale":"en_AU","output":"Month","outputType":"msg","outTz":"Australia/Sydney","x":2130,"y":770,"wires":[["68e9cfea.2a6958"]]},{"id":"4a7752ae.68805c","type":"debug","z":"1c428643.6f708a","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":2280,"y":890,"wires":[]},{"id":"8d2ef3ee.e58758","type":"moment","z":"1c428643.6f708a","name":"Year","topic":"","input":"payload","inputType":"msg","inTz":"Australia/Sydney","adjAmount":0,"adjType":"days","adjDir":"add","format":"YYYY","locale":"en_AU","output":"year","outputType":"msg","outTz":"Australia/Sydney","x":1940,"y":770,"wires":[["9e059740.fd1fa"]]},{"id":"cfd20db7.3c70c8","type":"link in","z":"1c428643.6f708a","name":"","links":["5918588f.1732d8"],"x":1825,"y":770,"wires":[["8d2ef3ee.e58758"]]},{"id":"f9f73963.10269","type":"inject","z":"1c428643.6f708a","name":"Test","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":1700,"y":720,"wires":[["8d2ef3ee.e58758"]]}]

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