Automatically updating n8n


Is there a way to automatically update n8n when running it via pm2?

Right now, I have to manually update it using the console every time, which is a hassle because I am just deploying it and not using it, so I don’t immediately notice when new updates are coming out.

Could I create a cron job for example, that runs a basic shell script that backs up the Workflows and then runs the npm update command for n8n?

Hey @Felix,

In theory that should be possible, There is a CLI tool you can use to export workflows so your script may look something like…

# Export n8n workflows to backups/latest/ folder
n8n export:workflow --all --output=backups/latest/
# Stop n8n
pm2 stop n8n
# Install the latest release
npm install -g [email protected]
# Start n8n up
pm2 restart n8n

This has not been tested but may help you work out your process, If you wanted to you could also export the credentials. What I do with my n8n instance is have a workflow that exports the workflows and commits them to a Git repo on a schedule, Makes life a bit easier and it is one less script I need to maintain.


Thanks, that worked!

I’ve changed the --all Flag to --backup and also backed up my credentials, but apart from that its working like intended. Thank you so much!

1 Like