Blog · · 5 min read
How to automatically back up your n8n workflows to Google Drive
Step-by-step guide to saving a copy of every n8n workflow to Google Drive each night, with failure alerts and automatic cleanup of old backups.

After a few weeks with n8n, your workflows start to be worth real money: the agent that answers customers, the one that logs invoices to Google Sheets, the appointment reminders… And one bad edit, a wiped server or a failed upgrade is all it takes to lose hours of work. The fix is simple: let n8n itself back up all your workflows every night.
In this guide you'll build an n8n workflow that reads all your workflows through the n8n API, turns each one into a dated JSON file and uploads it to a Google Drive folder, alerting you if anything goes wrong. If you don't have n8n running yet, start by installing n8n for free on your computer.
What you're going to build
A nightly five-step workflow:
- Schedule trigger: every night at 3:00.
- Read the workflows: the n8n node asks your own instance for the full list of workflows.
- Convert to file: each workflow is saved as a
.jsonwith its name and the date. - Upload to Google Drive: into a private "n8n backups" folder.
- Alert on failure: an error workflow emails you if the backup doesn't complete.
What you need
- An n8n instance with the public API enabled. It's included in self-hosted n8n; on n8n Cloud the API isn't available during the free trial.
- An n8n API key: in n8n, go to Settings → n8n API → Create an API key. Name it something like "backups" and store it safely; it's only shown once.
- Google Drive connected in n8n.
- A Drive folder called "n8n backups" (copy its ID from the URL: it's the part after
/folders/).
Step 1: create the n8n API credential
In n8n, create a credential of type n8n API:
- API Key: the key you just generated.
- Base URL: your instance address followed by
/api/v1, for examplehttps://n8n.yourdomain.com/api/v1, orhttp://localhost:5678/api/v1if it runs on your computer.
This key can access every workflow you have, so treat it like a password: don't paste it into notes or share it.
Step 2: the trigger and reading your workflows
- Add a Schedule Trigger that runs every day at 3:00 (or whenever you use n8n least).
- Add the n8n node with the Workflow resource and the Get Many operation. Turn on Return All so it fetches every workflow, not just the first page.
When you run it you'll see one item per workflow, with its name, nodes, connections and whether it's active. That's exactly what you need to restore it later.
Step 3: turn each workflow into a JSON file
Add a Convert to File node with the Convert to JSON operation and Each Item Separately mode, so each workflow becomes its own file.
For File Name, use an expression that combines the date and the workflow name, stripping odd characters:
{{ $now.toFormat('yyyy-MM-dd') }}_{{ $json.name.replace(/[^a-zA-Z0-9-_]+/g, '-') }}.json
You'll get files like 2026-10-26_whatsapp-agent.json, easy to find and sort.
Step 4: upload them to Google Drive
After Convert to File, add a Google Drive node with the Upload operation:
- Input Data Field Name:
data(the file the previous step just created). - Parent Folder: the "n8n backups" folder (pick it from the list or paste its ID).
Because every file name starts with the date, you don't need subfolders: Drive will show your backups sorted by day.
Step 5: clean up old backups
So Drive doesn't fill up, add a second branch from the trigger that removes anything older than 30 days:
- A Google Drive node with the Search operation (resource File/Folder), limited to the "n8n backups" folder with Return All on.
- A Filter node that only lets through files whose date in the name is earlier than the cutoff, comparing
{{ $json.name.slice(0, 10) }}as a string with{{ $now.minus({ days: 30 }).toFormat('yyyy-MM-dd') }}. - A Google Drive node with the Delete operation on those files.
If deleting makes you nervous, run just the first two nodes and check the list before adding the third. Deleted files go to the Drive trash, so you'll still have a window to recover them.
Step 6: get alerted when it fails
A backup that fails silently is almost worse than no backup. In the workflow settings (Settings → Error Workflow), pick an error workflow that sends you an email or a Telegram message. We cover it in detail in the guide to n8n error handling with alerts and retries.
Bonus tip: add a Gmail node that emails you every Monday with how many workflows were backed up. If a Monday goes by without it, you know something's off.
How to restore a workflow
When you need one back:
- Download the
.jsonfor the date you want from Google Drive. - In n8n, create a new workflow and use Import from File (in the three-dot menu), or just copy the contents and paste them onto the canvas.
- Check the credentials: workflows only store a reference to them, not the keys. If you restore into a different instance, you'll need to reselect them in each node.
- Activate it again once you've tested it.
Common mistakes and best practices
- The backup doesn't include credentials: that's expected and a good thing, since your keys don't end up in Drive. If you self-host, keep the
N8N_ENCRYPTION_KEYvariable somewhere safe: without it you can't decrypt the credentials in your database if you move servers. - 401 error on the n8n node: the key was copied wrong or the Base URL doesn't end in
/api/v1. - Only some workflows show up: check that Return All is on.
- Shared folders: keep backups in a private folder. Workflows can contain internal URLs, sheet IDs or prompt text you don't want public.
- Test a restore at least once. A backup you've never restored is just an assumption.
Start with ready-to-import templates
If you want workflows worth protecting from day one, download the free WhatsApp agent or check out the full AgentKiosk pack: 8 tested n8n agents in English and Spanish, ready to import, and with this nightly backup you'll never lose your tweaks.


