Quick Overview
This workflow backs up all n8n workflows and encrypted credentials from a self-hosted Docker instance to a GitHub repository on a schedule, and provides a Basic Auth–protected form to restore workflows and credentials by importing uploaded JSON backup files over SSH.
How it works
- Runs twice daily on a cron schedule to start a backup run.
- Creates timestamped
workflows and credentials folders (via placeholder files) in the target GitHub repository.
- Connects to the Linux host over SSH and runs the n8n CLI in the Docker container to export all workflows and all encrypted credentials.
- Commits
workflows-all.json and individual <workflow name>.json workflow backups to GitHub.
- Commits
credentials-all.json and individual <name>_<type>.json encrypted credential backups to GitHub.
- Builds and commits a combined
workflows-credentials.json file containing both exports for easy restoration.
- Accepts uploaded JSON files via a Basic Auth form, detects whether they contain workflows or credentials (single, bulk, or combined), and imports them into the target n8n Docker container over SSH.
Setup
- Create a private GitHub repository and add GitHub API credentials in n8n with permission to write files to that repository.
- Add SSH credentials for your Linux host and ensure the SSH user can run
docker exec/docker cp against the n8n container.
- Update the Backup Configuration and Restore Configuration nodes with your GitHub owner, repository name, and the n8n Docker container name.
- Configure Basic Auth credentials for the restore form and deploy it behind HTTPS before activating the restore path.
- Ensure the destination n8n instance uses the same
N8N_ENCRYPTION_KEY as the source so encrypted credentials can be restored.