How to Backup Your Workflow (GitHub)

You need a process to back up your workflows in case they get deleted.
Workflows can be exported and imported in two ways:
In the editor UI :
Export:
From the top navigation bar, select the three dots in the top right corner, then select Download . This will download the current workflow to your computer as a JSON file.
Import:
From the top navigation bar, select the three dots in the top right, then select Import from URL (to import a published workflow) or Import from file (to import a workflow as a JSON file).
From the command line:
Export:
See the full list of commands for exporting workflows or credentials .
Import:
See the full list of commands for retrieving workflows or credentials .

How to back up to GitHub

How to auto-backup n8n workflows to GitHub
Result
You can check that it is imported well as follows.
If you reload it, you can restore it by copying the contents and re-entering them into the n8n workflow.

N8n API Test

You can check the list of currently active workflows by running the command below in the terminal.
curl -X 'GET' \ 'http://localhost:5678/api/v1/workflows?active=true' \ -H 'accept: application/json' \ -H 'X-N8N-API-KEY: <api_key>'