AutomationFlowsGeneral › Automated N8n Credential Backups to Google Drive with Scheduled Execution

Automated N8n Credential Backups to Google Drive with Scheduled Execution

ByDaniel Ng @danielng on n8n.io

This n8n workflow template uses community nodes and is only compatible with the self-hosted version of n8n.

Event trigger★★★★☆ complexity9 nodesExecute CommandGoogle Drive
General Trigger: Event Nodes: 9 Complexity: ★★★★☆ Added:

This workflow corresponds to n8n.io template #4517 — we link there as the canonical source.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "a0wJocTNabVjrlee",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AIAutomationPro Backup Credentials To Google Drive",
  "tags": [],
  "nodes": [
    {
      "id": "550155aa-dfd0-4bbe-b3c7-26891c1903dd",
      "name": "On Click Trigger",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        60,
        280
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "000cbe87-24bb-41a2-a6db-4dc12529b191",
      "name": "Execute Command Get All Cridentials",
      "type": "n8n-nodes-base.executeCommand",
      "position": [
        520,
        280
      ],
      "parameters": {
        "command": "npx n8n export:credentials --all --decrypted"
      },
      "typeVersion": 1
    },
    {
      "id": "1d6c568b-1bbd-458c-b5c9-d209a6cc44e5",
      "name": "JSON Formatting Data",
      "type": "n8n-nodes-base.code",
      "position": [
        720,
        280
      ],
      "parameters": {
        "jsCode": "// Function to beautify JSON\nfunction beautifyJson(jsonString) {\n  try {\n    // Parse the JSON string\n    const jsonObject = JSON.parse(jsonString);\n\n    // Format the JSON with indentation\n    return jsonObject; // Return the parsed object directly\n  } catch (error) {\n    // Return the error message if JSON is invalid\n    return `Invalid JSON: ${error.message}`;\n  }\n}\n\n// Retrieve the JSON object from the input data\nconst input = $input.all()[0].json;\n\n// Extract the JSON string from the stdout field\nconst jsonString = input.stdout.match(/\\[{.*}\\]/s);\n\n// Check if a valid JSON string is found\nif (!jsonString) {\n  return {\n    json: {\n      error: \"No valid JSON string found in stdout.\"\n    }\n  };\n}\n\n// Beautify the JSON\nconst beautifiedJson = beautifyJson(jsonString[0]);\n\n// Output the beautified JSON, ensuring each entry is in an object with a 'json' key\nconst output = beautifiedJson.map(entry => ({ json: entry }));\n\n// Return the output\nreturn output;\n"
      },
      "typeVersion": 2
    },
    {
      "id": "2c41e6b0-b1c2-4102-a37f-403b5438caf3",
      "name": "Aggregate Cridentials",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        920,
        280
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "d6a08fd5-16c6-4746-ab23-9dd956eda393",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        420,
        200
      ],
      "parameters": {
        "width": 911,
        "height": 292,
        "content": "## Export All Credentials From N8n"
      },
      "typeVersion": 1
    },
    {
      "id": "458c133d-ce5e-4fc5-9af5-79b04e86a18d",
      "name": "Convert To File",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        1120,
        280
      ],
      "parameters": {
        "options": {},
        "operation": "toJson",
        "binaryPropertyName": "=data"
      },
      "typeVersion": 1.1
    },
    {
      "id": "0e39d74f-53ee-4b9e-b213-97bfaa605e78",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        200
      ],
      "parameters": {
        "width": 311,
        "height": 292,
        "content": "## Google Drive Folder"
      },
      "typeVersion": 1
    },
    {
      "id": "afd3b1ce-bd9e-4dda-bb9a-d27f343f57a1",
      "name": "Google Drive Upload File",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1540,
        280
      ],
      "parameters": {
        "name": "=n8n_backup_credentials.json",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1p447S9MWYcRpA6dmfDe-Kdc3-d8L2Lzr",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1p447S9MWYcRpA6dmfDe-Kdc3-d8L2Lzr",
          "cachedResultName": "Tung Backup Credential"
        },
        "inputDataFieldName": "=data"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "62a9e8c8-9731-459b-98c7-9befaf4c7cce",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        60,
        480
      ],
      "parameters": {
        "rule": {
          "interval": [
            {}
          ]
        }
      },
      "typeVersion": 1.2
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "35978b6b-b4a2-4fce-a3bf-3ecf1f6c3e55",
  "connections": {
    "Convert To File": {
      "main": [
        [
          {
            "node": "Google Drive Upload File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "On Click Trigger": {
      "main": [
        [
          {
            "node": "Execute Command Get All Cridentials",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Execute Command Get All Cridentials",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "JSON Formatting Data": {
      "main": [
        [
          {
            "node": "Aggregate Cridentials",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Cridentials": {
      "main": [
        [
          {
            "node": "Convert To File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Execute Command Get All Cridentials": {
      "main": [
        [
          {
            "node": "JSON Formatting Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This n8n workflow template uses community nodes and is only compatible with the self-hosted version of n8n.

Source: https://n8n.io/workflows/4517/ — original creator credit. Request a take-down →

More General workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

General

Batch-convert CAD/BIM files to analysis-ready XLSX and optional DAE with automatic verification and a clean HTML report. Runs locally via and PowerShell on Windows.

Execute Command, Write Binary File
General

Back up n8n workflows to Google Drive automatically This workflow provides a robust solution for backing up your n8n workflows to Google Drive. It is designed to handle backups for multiple n8n instan

Execute Workflow Trigger, n8n, Google Drive
General

This n8n workflow provides automated rsync backup capabilities between servers using password authentication. It automatically installs required dependencies, performs the backup operation from a sour

Execute Command
General

Batch watermark every image in a Google Drive folder and save the results to a separate destination folder — fully automated, no code required, and no external tools or APIs needed.

Google Drive, Edit Image