Adding Date to the Hassio Snapshot Name

I have configured a Node Red flow to run the ‘snapshot_full’ hassio service once a week to create automated backups. The problem I’m having is getting the snapshot name to include the current date. I’ve tried using the following JSON in the Data parameter, but the date is not parsed and/or appended. All snapshots end up with the same name of "Automated Backup ".

{
    "name": "Automated Backup {{ now().strftime('%Y-%m-%d') }}"
}

Any thoughts on what I’m doing wrong?

After more searching, I figured this one out. The now().strftime function doesn’t work here. Instead you have to use a Moment node to format the date/time prior to using it in the service call.

[{"id":"997eaff.ed4025","type":"inject","z":"c229ea9e.b08cb8","name":"Sundays at 4:00 AM","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"00 04 * * 0","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"str","x":180,"y":120,"wires":[["ee87078b.499f68"]]},{"id":"ee87078b.499f68","type":"moment","z":"c229ea9e.b08cb8","name":"","topic":"","input":"","inputType":"msg","inTz":"America/New_York","adjAmount":0,"adjType":"days","adjDir":"add","format":"MMM/DD/YYYY hh:mma","locale":"C","output":"","outputType":"msg","outTz":"America/New_York","x":400,"y":120,"wires":[["f6fa4f0c.1fafe"]]},{"id":"f6fa4f0c.1fafe","type":"api-call-service","z":"c229ea9e.b08cb8","name":"Create Full Snapshot","server":"e0694c61.ea2fd","version":1,"debugenabled":false,"service_domain":"hassio","service":"snapshot_full","entityId":"","data":"{\"name\":\"Backup {{payload}}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":620,"y":120,"wires":[[]]},{"id":"e0694c61.ea2fd","type":"server","name":"Home Assistant","addon":true}]

Are you aware of the HA Add-on https://github.com/sabeechen/hassio-google-drive-backup this does what you want, but also creates and manages a copy in the cloud. Saved me more than once especially if one is using a RPi with and SD card.

2 Likes

Thank you!! I had searched and found a few options, but they were overly complicated from a configuration/installation perspective. This looks perfect for me. Thanks again!

Just wanted to share with anyone else who comes across this. I finished setting up the Hassio Google Drive Backup add-on and wow was it easy. Well written instructions, and a very simple process. Only took about 10 minutes and now I have automated backups syncing to my Google Drive. SOOOO much easier than setting it all up yourself.

At least now I won’t have to restore whatever files I can from the SD card using an Ubuntu laptop after a crash! Live and learn!!