⚙️ Automated workflow backups from self-hosted n8n to Google Drive with version history

925 views · ⚙️ DevOps & CI/CD

Description

✅ What problem does this workflow solve?

If you’re using a self-hosted n8n instance, there’s no built-in version history or undo for your workflows. If a workflow is accidentally modified or deleted, there’s no way to roll back. This backup workflow solves that problem by automatically syncing your workflows to Google Drive, giving you version control and peace of mind.


⚙️ What does this workflow do?


🔧 Setup Instructions

1. Google Drive Setup

2. n8n API Credentials

3. Schedule the Workflow


🧠 How it Works

Step-by-Step Flow:

  1. Scheduled Trigger

    • The workflow begins on a timed schedule using the Cron node.
  2. Fetch All Workflows

    • Uses the n8n API (/workflows) to retrieve a list of all existing workflows.
  3. Loop Through Workflows

    • For each workflow:
      • A folder is created in Google Drive using the workflow name.
      • The workflow’s last updated timestamp is checked against Google Drive backups.
  4. Smart Change Detection

    • If the workflow has changed since the last backup:
      • A new .json file is uploaded to the corresponding folder.
      • The file is named with the last updated date of the workflow (YYYY-MM-DD-HH-mm-ss.json) to maintain a versioned history.
    • If no change is detected, the workflow is skipped.

🗂 Google Drive Folder Organization

Backups are neatly organized by workflow and version:

/n8n-workflow-backups/
├── google-drive-backup-KqhdMBHIyAaE7p7v/
│ ├── 2025-07-15-13-03-32.json
│ ├── 2025-07-14-03-08-12.json
├── resume-video-avatar-KqhdMBHIyAaE8p8vr/
│ ├── 2025-07-15-23-05-52.json

Each folder is named after the workflow’s name+id and contains timestamped versions.


🔧 Customization Options


♻️ How to Restore a Workflow from Backup

  1. Go to the Google Drive backup folder for the workflow you want to restore.
  2. Download the desired .json file (based on the date).
  3. Open your self-hosted n8n instance.
  4. Click Import Workflow from the sidebar menu.
  5. Upload the JSON file to restore the workflow.

> You can choose to overwrite an existing workflow or import it as a new one.


👤 Who can use this?

This template is ideal for:


📣 Tip

Consider enabling version history in Google Drive so you get even more fine-grained backup recovery options on top of what this workflow provides!


🚀 Ready to use?

Just plug in your n8n token, connect Google Drive, and schedule your backups. Your workflows are now protected!

🔗 Nodes Used

Google Sheets, Google Drive, n8n, Schedule Trigger

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup