3.6 KiB
Automating Backups with n8n
!!! info This guide was submitted by a community member. Find something wrong? Submit a PR to get it fixed!
n8n is a free and source-available fair-code licensed workflow automation tool. It's an alternative to tools like Zapier or Make, allowing you to use a UI to create automated workflows.
This example workflow:
- Creates a Mealie backup every morning via an API call
- Keeps the last 7 backups, deleting older ones
!!! warning "Important" This only automates the backup function, this does not backup your data to anywhere except your local instance. Please make sure you are backing up your data to an external source.
Setup
Deploying n8n
Follow the relevant guide in the n8n Documentation
Importing n8n workflow
-
In n8n, add a new workflow
-
In the top right hit the 3 dot menu and select 'Import from URL...'
-
Paste
https://github.com/mealie-recipes/mealie/blob/mealie-next/docs/docs/assets/other/n8n/n8n-mealie-backup.jsonand click 'Import' -
Click through the nodes and update the URLs for your environment
API Credentials
Generate Mealie API Token
-
Head to
<YOUR MEALIE INSTANCE>/user/profile/api-tokens!!! tip If you dont see this screen make sure that "Show advanced features" is checked under
<YOUR MEALIE INSTANCE>/user/profile/edit -
Under token name, enter the name of the token (for example, 'n8n') and hit 'Generate'
-
Copy and keep this API Token somewhere safe, this is like your password!
!!! tip You can use your normal user for this, but assuming you're an admin you could also choose to create a user named n8n and generate the API key against that user.
Setup Credentials in n8n
See also n8n Docs.
-
Create a new "Header Auth" Credential
-
In the connection screen set - Name as
Authorization- Value asBearer {INSERT MEALIE API KEY} -
In the workflow you created, for the "Run Backup", "Get All backups", and "Delete Oldies" nodes, update:
- Authentication to
Generic Credential Type - Generic Auth Type to
Header Auth - Header Auth to
Mealie APIor whatever you named your credentials
- Authentication to
Notification Node
!!! warning "Important" Please use error notifications of some kind. It's very easy to set and forget an automation, then have the worst happen and lose data.
ntfy is a great open source, self-hostable tool for sending notifications.
If you want to use ntfy, you will need to install it on your environment, or sign up for their service, and configure it with the webhook URL.
If you want to use another notification service, you can create a new node in n8n that sends the notification using whatever method you like.
- For example, if you want to send a push notification via Pushover you could create a new node that uses the Pushover API and sends the notification.
- You can use the Send Email node in n8n as an example of how to create your own custom node.
- You can send it off to InfluxDB, Slack, Discord etc. Go nuts.
If you're using another method for backups we'd love to hear about it. Pop in Discord and say hi!




